I love forks, and they are useful for everything!!!!

to use a traditional language example

a =. (x) f y  NB. function of 1 or 2 arguments passed to function. assign to 
temp var a
b =. (x) g y  NB. Other function using passed arguments
c =.  b h a NB. combine the above 2 results with h function.
NB. could return c here
return. (x or y) h2 c  NB. combine previous result with either original x or y 
arguments

with the last step being the y argument, this is the equivalent fork

(] h2 g h f)

the main reason you have intermediate results in other languages is that you 
need to combine them later with another function.  Forks provides a clean and 
terse way of doing so.


----- Original Message -----
From: 'Dan Baronet' via Programming <programm...@jsoftware.com>
To: "programm...@jsoftware.com" <programm...@jsoftware.com>
Cc: 
Sent: Wednesday, July 16, 2014 4:26:38 PM
Subject: [Jprogramming] trains

I am looking for good examples of use of trains.
Apart from the classic +/ % #, I can't think of many more.
Anyone with some examples? They can be of any length.
/Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to