On Sat, Oct 8, 2011 at 6:23 AM, David Vaughan <purpleblue...@googlemail.com> wrote: > Hi, I am looking to repeatedly apply a verb on itself until a > certain value is reached, with the prior knowledge that there are > two values that can be reached. The idea is to count how many times > one of the two values comes up. I know about the power verb but I'm > not sure how to use it properly beyond the simple v^:n y form. I've > read about using it like a C while loop but in my case, there are > two values I want to 'exit the loop' with. > > Any pointers? Thanks.
Depending on what specifically you are trying to do, ^: may or may not be the right thing to use. The issue is that ^: assumes that it is dealing with a mathematical function. If its function gives the same result twice in a row, it will stop right there. This is how ^:(test)^:_ works something like a while loop -- when (test) returns false, the inner ^: becomes an identity function and the outer ^: knows that it's time to stop. That said, note that ^: functions -- like pretty much everything else in J -- can take list arguments and produce list results. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm