From: Morton Goldberg Date: 2007-11-12T12:26:52+09:00 Subject: Re: The Man or Boy Recursion Test On Nov 11, 2007, at 8:46 PM, Tim Hunter wrote: > Morton Goldberg wrote: >> On Nov 11, 2007, at 6:42 PM, Tim Hunter wrote: >>> Ummmm...before I wrote C I wrote PL/I. Not a lot, but enough to >>> be able to use the PL/I version of the Man or Boy test to figure >>> out how to code the Ruby version. >> Interesting. I used your Ruby version to figure out how to code it >> in Mathematica. I was able to make a fairly direct translation. >> >> $RecursionLimit = 1665; (* anything less fails for k0 = 10 *) >> a[k0_, x1_, x2_, x3_, x4_, x5_] := Module[{k, b }, >> k = k0; >> b = (k--; a[k, b, x1, x2, x3, x4]) &; >> If[k <= 0, x4[] + x5[], b[]]] >> a[10, 1 &, -1 &, -1 &, 1 &, 0 &] (* => -67 *) >> >> Note how compact the Mathematica notation for the thunks is. >> Regards, Morton > > Another one for Wikipedia. I've posted it there. I like the Smalltalk example also -- very concise yet still readable. > I guess we owe Werner (the OP) a big "thanks" for introducing such > an interesting thread. Thanks, Werner! Indeed. Regards, Morton