Thanks to everyone that replied, although I am not comfortable at reading Raul Miller's solution, I am still interested in other ways to solve my problem. I have only scratched the surface with hooks and forks , as I found them quite difficult to understand on my first read through.
My actual problem is slightly more complicated than my original post, but I wanted to simplify it to understand it better. If I was to extend it slightly, I have this c=: 4 : '(!(x+y)) % (x+y)' a=: 1 2 3 4 5 and the result I want are a c 1 1 2 6 24 120 a c 2 2 6 24 120 720 a c 3 6 24 120 720 5040 To do this without a loop, I came up with this b=: 1 2 3 NB. First Approach a c b |length error: c | (!(x+y))%(x +y) One might think so but this is not true. > "/" itself is not causing an "each on each". Thank you for explaining that as my second approach went something like this NB. Second Approach a c/ b |length error: c | (!(x+y))%(x +y) Finally I simplified 'c' a section at a time until I came up with c2=: 4 : '(!(a+/b)) % (a+/b)' NB. Third Approach a c2 b 1 2 6 2 6 24 6 24 120 24 120 720 120 720 5040 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
