Hello!

I hope this is not too simple a question for this list, but I'm still learning 
J and wonder how to do a simple backtracking in J.
For instance, I might want to see what is the longest string consisting of a,b, 
and c, that fulfills some property P.
In any imperative language (here: ruby) I would do something like this…

def bk(w)
   if (!P(w)) return
   bk(w+"a")
   bk(w+"b")
   bk(w+"c")
end
bk("")

…and combine it with some bookkeeping of which was the longest that I've seen 
so far and maybe some output every 100 steps,
if there is actually no longest one (that is, there is an infinite one 
fulfilling P).

I'm very interested how to do these kind of things elegantly in J.

Best regards,
Mike
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to