(g y) f (g y) is indeed the same as (f~@:g) y What does "pass the parameter y to the function f before it is applied" mean? For example, does it mean y f (g y) ?
(# ,:@i.) 5 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 (,~ $ i.) 5 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 (| i.@,~) 5 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 ----- Original Message ----- From: Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]> Date: Tuesday, September 26, 2006 8:10 pm 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
