I don't quite get the question either, but looking at your examples I think you might find the following interesting:
sol3 =: # ,:@:i. sol3 3 0 1 2 0 1 2 0 1 2 sol4 =: # i.@:(1&,) sol4 3 0 1 2 0 1 2 0 1 2 Learn about Hooks to see that (f g) y is y f (g y) . Is that what you want? Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Yuvaraj Athur Raghuvir > Sent: Tuesday, September 26, 2006 11:10 PM > To: Programming forum > Subject: [Jprogramming] Exploring Reflex & How to factor out > the argument > > Hello, > > I am not sure if I understand the '~' (reflex) adverb right. > > 1) Is the following true? > (f~ @: g)y is the same as (gy) f (gy). > > 2) Now, I want to pass the parameter y to the function f before it is > applied. Is that possible? > > Regards, > Yuva > > Example: (absolute beginner exploration...optimal versions > are welcome!) > > NB. create a n by n matrix with 0 to (n-1) repeated n times > n =. 3 > NB. solution1: ravel the laminations n-1 times > (,: i.n) ,^: (<:n) (,: i.n) > 0 1 2 > 0 1 2 > 0 1 2 > NB. hmmm... looks like the n can be factored out... > NB. I see a reflex form, and then a power.... > NB. so, > sol1 =: (,^: (<:])~) @: (,: i.) > $ sol1 n > 2 3 4 3 > NB. Oops! The n has not reached the inner function. Is the > form right?? > > NB. Another way using transpose.... > sol2 =. |: @: (#"0 i.)~ > sol2 n NB. works as intended > 0 1 2 > 0 1 2 > 0 1 2 > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
