See http://www.jsoftware.com/jwiki/Essays/Knight's_Tour for an example (I
think).
On 2013-06-26 1:37 AM, "Mike Müller" <[email protected]> wrote:
> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm