I love it! (was Gaus) 
Author Message
 I love it! (was Gaus)

As some of you already know I am learning J in my free time (about 15
minutes a day... :-( ), and without any basic documents (like the
dictionary). So it is not surprising that I make stupid mistakes. But I
love to learn from them. So thans for all your comments.
Some remarks though:
1. I thought about reversing the array (vector), but did it using the
idea of an arithmatic progression as an exercise. Not beacause I am brain
dead!
2. I loved to see the other (and all of them better) ways of doing it. It
just show how rich J is. But it still doesn't answer my question - isn't
J (and APL) too rich?
3. I want to give special mention to Roger for teaching me that i. _n
results in the reverse of i. n. J's and APL's operator vocabulary is very
complete in the sense that (especially in J) operators have the *right*
meaning in so many contexts. In J with rank etc. it is really amazing.
Thanks - it makes me a happier person.

P.S
 I think that by having such extremely small examples available (maybe by
FTP) can really help beginners. I learned many languages by now and most
of them just by looking at examples. Since J is so different than other
languages most examples will be too complicated for a beginner. But maybe
such small examples + some short commentary can help someone just making
his first J steps. Comments?

--



Sun, 13 Jul 1997 01:06:48 GMT  
 I love it! (was Gaus)

Quote:

>As some of you already know I am learning J in my free time (about 15
>minutes a day... :-( ), and without any basic documents (like the
>dictionary). So it is not surprising that I make stupid mistakes. But I
>love to learn from them. So thans for all your comments.
>Some remarks though:
>1. I thought about reversing the array (vector), but did it using the
>idea of an arithmatic progression as an exercise. Not beacause I am brain
>dead!
>2. I loved to see the other (and all of them better) ways of doing it. It
>just show how rich J is. But it still doesn't answer my question - isn't
>J (and APL) too rich?
>3. I want to give special mention to Roger for teaching me that i. _n
>results in the reverse of i. n. J's and APL's operator vocabulary is very
>complete in the sense that (especially in J) operators have the *right*
>meaning in so many contexts. In J with rank etc. it is really amazing.
>Thanks - it makes me a happier person.

>P.S
> I think that by having such extremely small examples available (maybe by
>FTP) can really help beginners. I learned many languages by now and most
>of them just by looking at examples. Since J is so different than other
>languages most examples will be too complicated for a beginner. But maybe
>such small examples + some short commentary can help someone just making
>his first J steps. Comments?

>--


Ehud Lamm is right about the need for examples: useful, quirky, elegant, ASCII -  whatever it takes to
defend the consumption of a few thousand bytes of bandwidth. The code below allows the easy creation of
very large arrays of controls. The usefulness of this concept is proportional to the number of input/output
points that a machine control system has or any other system for that matter.  The need to reference a
hundred control points on one screen simultaneously is quite common but frequently not addressed by many
PLC progamming systems (DIRECTSOFT for example, currently the best in the Biz). I believe this is due to
the difficulty in creating and referencing arrays of controls. The code is also useful for testing the
limits of a given windows driver system as well as anyones decoding patience including mine in a few days.

This points out the need for some sort of parsing program that takes any code and executes it thunk by
chunk printing out the operators, operands with intermediate results. With such a program there is not much
difference between a 1 and 50 liner in terms of readability and didactic usefulness. This one program would
have saved me hundreds of hours of decoding. With it I could decipher in seconds what can take 30 minutes
to understand. Maybe someone can tell me why such a program with such obvious usefulness is not available
as a system function much less a utility program with every system? I too have limited time each day for
programming. With such a program a novice could probably understand controlarray completely in one hour and
the dictionary in two.                

append=. 3 : 0
:
NB. right justify vector before appending right arg.
((-+/*/\|. ' '= x.)|.x.),y.
)

wd=. 11!:0

controlarray=. 3 : 0
NB. controlarray  
('type';'style';'specs';'dim';'xyoffset';'cciname';'screenlabel')=:y.


NB. local verbs that format vector of numbers and inserts '.' or ';' between numbers

coords2=:        {i.&.>dim
ccicoordtags=:   >charinsert1 &.> ,coords2

if.              screenlabel -: ''    do.
labelcoordtags=: ,.(*/dim)#,' '
screenlabel=:    ' '

elseif.          2=$$screenlabel      do.
labelcoordtags=: ,.(*/dim)#,' '
screenlabel=:    '"',.screenlabel,.'"'

elseif.          1=$$screenlabel      do.
labelcoordtags=: (>charinsert2 &.> ,coords2),.'"'
screenlabel=:    '"',.(>(*/dim)#<screenlabel),.' '
end.

offset1=:        ":(0 1{specs)+"1>(<xyoffset)*&.>coords1
xywh=:           'xywh ',"1 offset1,"1  ' ',":2 3{specs
line1=:          'xywh ' ,(":specs),'; cc ',(0{cciname) append 0{ccicoordtags
line1=:          line1, ' ',type,' ',style,'; cn ',(0{screenlabel),(0{labelcoordtags),';'
mat1=:           xywh,. ';',. 'cci ',"1 cciname append "1 ccicoordtags,.';'
mat1=:           mat1 ,. 'cn ',"1 screenlabel,"1 labelcoordtags,. ';'
line1,mat1
)

buttonarraydemo=. 3 : 0
NB. try  buttonarraydemo 3 3   y. is row/column size of control array
z=:   >(*/y.)$<;._1  '/pump 1/pump 2/pump 3/valve 1/valve 2/valve 3/switch 1/switch 2/switch 3'
n=:   >(*/y.)$;: 'pump pump pump valve valve valve switch switch switch'
wd    'pc FluidPumping;pas 500 300;pcloseok;'
wd    'fontdef -12 0 0 0 700 0 0 0 0 1 2 1 34 "Times New Roman";'
z=.   controlarray 'button';'bs_autocheckbox';7 15 35 10; y. ;40 40;n;z
wd    ,z
wd    'pas 5 5;pcloseok;pshow;'
z
)

editarraydemo=. 3 : 0
NB. try editarraydemo 6 6    y. is row/column size of control array
wd   'pc FluidPumping;pas 500 300;pcloseok;'
wd   'fontdef -12 0 0 0 700 0 0 0 0 1 2 1 34 "Times New Roman";'
z=.  controlarray 'edit';'ws_border es_autohscroll';7 15 30 10; y. ;40 40;'p';'Pump'
wd   ,z
wd   'pas 5 5;pcloseok;pshow;'
z
)

comboboxarraydemo=. 3 : 0
NB. try comboboxarraydemo 5 5   y. is row/column size of control array
wd   'pc FluidPumping;pas 500 300;pcloseok;'
wd   'fontdef -12 0 0 0 700 0 0 0 0 1 2 1 34 "Times New Roman";'
z=.  controlarray  'combobox';'cbs_autohscroll cbs_sort cbs_dropdown ws_vscroll';7 15 60 50;y.;65 50;'p';''
wd   ,z
wd   'pas 5 5;pcloseok;pshow;'
z
)



Sun, 13 Jul 1997 13:46:18 GMT  
 I love it! (was Gaus)
In fact right now I am considering using the public J version to produce
a version of the parser that will only tell me what is going on. It
started by adding debug printfs when I tried to figure out the parser.

This again raises the question I raised a couple of times: If the J
version which is available with source, will be made easier to handle -
since now the code lacks some 5 pages of documentation needed, and
comments; the result can help to build other useful tools, and help
people learn the language.

These things may be done by me - but only when I feel I mastered enough J...

--



Sat, 19 Jul 1997 06:01:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MF Visual Object COBOL - Love it, hate it, love it

2. Are you good sports? (was Gaus)

3. +/i., Gaus, and J

4. I am not deaf, but am I mute?

5. How to parse "I say: 'I love you'" to [I, say, I love you]

6. From Russia with love

7. DARCY Loves You 2448

8. Your GOD Loves You - YES YOU!

9. Your GOD Loves You - YES YOU!

10. I love REALbasic :P

 

 
Powered by phpBB® Forum Software