making J simple 
Author Message
 making J simple

One of the best ways to see how J operates is
to create something simple and use out to tell you
what is happening. Like this:

ONE=:0

out=: 1!:2&2

one=: 3 : 0
out '     here comes one'
out y.
2
out'ONE is:  ',": ONE=:>:ONE
)
one ''

two=: 3 : 0
out ' ....and here is two'
out y.
33
)

(empty two  AFTER  one  AFTER one AFTER two AFTER one )  1 2 3 4

here comes one
1 2 3 4
         ONE is:  1
 ....and here is two
         ONE is:  1
     here comes one
33
         ONE is:  2
     here comes one
         ONE is:  2
         ONE is:  3
 ....and here is two
         ONE is:  3

This way a seemingly coplicated statement breaks down into simple
easily understood operations.

Try then looking at it in J

f=:   (empty two  AFTER  one  AFTER one AFTER two AFTER one )

 f

   ff=: f f.
and now look at ff

ff

out '     here comes one'
out y.
2
out'         ONE is:  ',": ONE=:>:ONE
)
out ' ....and here is two'
out y.
33
)
out '     here comes one'
out y.
2
out'         ONE is:  ',": ONE=:>:ONE
)
out '     here comes one'
out y.
2
out'         ONE is:  ',": ONE=:>:ONE
)
out ' ....and here is two'
out y.
33
)

This is pretty much like looking at source code.

Try it at home and try to use box or tree display and
you will notice the difference.

Because you knew from the start how simple this was
then you can begin to look at what you before considered
VERY complicated J statements and begin to see similarities
with what you wrote here above and you know that this is
NOT really as complicated as you tought to begin with.

I bet this is clear as mud by now so I stop before I complicate
it even further. The compilation I was waiting for is also finished
so I have to stop playing with my J. It is very easy to work with
c++ you add a few lines to the project, start a compilation and then you wait
for an hour before you can see how it goes.
/Gosi



Fri, 31 Dec 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. JS-EAI with *JS*-callback

2. js.exception 3279.js

3. -> Computer Programming Made Simple <-

4. Making simple gates out of LPM libraries

5. Making a boostrap and simple command-line program

6. gtcatalog (was: "Re: Simple, customizable PHP shopping cart?", but google made me change it)

7. Continuations Made Simple (hopefully) and Illustrated

8. NB. gray.js: a J verb that generates a grayscale postscript image from a 2d array

9. lapackTest.js

10. profile.js

11. J script file profile.js

12. JS valueOf() in RB ?

 

 
Powered by phpBB® Forum Software