I also try to avoid recursion for several reasons but, for the case at hand, the code is very terse and found the solution hundreds of times without any problem.
Regarding "while," it implements, in general, a companion flipping boolean (similar to the "negating") to avoid exiting due to a "premature" convergence. The code is complicated because it is defined in a way that both arguments (the verbs) appear only once in the generated code (it also forces the exiting boolean condition to be a scalar to avoid "surprises"). This feature is important, to me, because typically the code that defines those verbs (particularlly the left argument) can be very large in my applications. Of course, I would gladly use a simpler general alternative that retains the feature(s) that I mentioned, if you or any one else, can find it and share it. ________________________________ From: Dan Bron <[email protected]> To: Programming forum <[email protected]> Sent: Friday, October 9, 2009 7:19:58 PM Subject: Re: [Jprogramming] Limit limitation I said: > I'm seeking a stylish workaround to the a constraint on applications of > ^:_ . Raul responded: > Construct iteration arguments as a list and use / to iterate. I agree this is a useful idiom, if your problem can be rephrased this way. However, only algorithms that have a fixed number of iterations are amenable to such rephrasing, unless you can correct me. This algorithm is nondeterministic and so cannot be phrased in terms of a fixed number of iterations: > Include a "generation counter" in your domain (or perhaps a bit > which you always invert). Yes, I already considered this approach: > that is, concatenating a boolean and negating it every iteration In fact, it is the one I adopted. However, I do not consider it "stylish". Jose wrote: > this is what I currently use instead of U^:V^:_ in similar situations: I have to study this "while" -- at first glance, it seems to be more complicated than neccesary. Can you explain its operation at a high level? > For recursive alternatives to u while v see > http://www.jsoftware.com/pipermail/general/2005-July/023272.html > evolve=. ]`([ $: f)@.done I avoid recursion in J if I can; it's unreliable (because the language doesn't optimize tail calls, it has a low, artificial, compiler-imposed limit on stack depth). > I guess Dan really meant: Yep, you got it. -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
