From: Tim Hunter Date: 2007-11-12T10:46:20+09:00 Subject: Re: The Man or Boy Recursion Test 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 guess we owe Werner (the OP) a big "thanks" for introducing such an interesting thread. Thanks, Werner! -- RMagick OS X Installer [http://rubyforge.org/projects/rmagick/] RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618] RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]