> In Elton Wang's implementation, I can see one trivial change that might help: > >> +/+/+/(57=x+/y+/z)*x</y*y</z >> Where x=.y=.z=i.29 > > could instead use > +/,(57=x+/y+/z)*x</y*y</z
Oh yes, good point. Is there a way to test resource (cpu, mem, time) usage within J? > or, if you prefer > +/,((57=[+/+/)*[</]*</)~i.29 That was a huge step for me. Thanks for pushing me! As I understand it, you first use the fact that x equals y equals z (don't know yet how to represent it correctly in J) then you replace z with [ and ]. That's the main difficulty for me as it changes the structure from something linear (reading-wise) to embedded trains. Then I tried to create the corresponding function and used @ (or should I use @: … rank usage is not perfectly clear for me yet) creating new forks to avoid an unwanted one: fun =: +/@,@((57=[+/+/)*[</]*</)~@i. (9!: helped me to check I did it right, thanks!) I was surprised a few times by this expression: 1. the ~ applies to the whole left fork instead of just to the parentheses! 2. at first I thought I should add a & so that I got (57&=[+/+/) but it didn't worked as expected 3. is there a reason to use [ *and* ] instead of only ] ? > (It's interesting to think about why I used [</] instead of </ I tried to understand. Is it because the form with [</] is equivalent to rank 3 “z </ z * (z</z)” but </ only leads to rank 2 “(z</z) * (z</z)”? I'm still trying to convert it to a function I could use directly: nfun 57 This seems a good exercice but might take me some time to solve. Thanks again. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
