From: Tim Hunter Date: 2007-11-11T06:17:51+09:00 Subject: Re: The Man or Boy Recursion Test Werner wrote: > Hello, > > being new to ruby I try to understand the language. In a different > context I came across the following: > > http://en.wikipedia.org/wiki/Man_or_boy_test > > Out of curiosity I tried to write an equivalent piece of code in ruby > but apparently my depth of knowledge is not good enough. > > Is there anyone who could enlighten me? > > Thanks and Best Regards > > Werner Dahn > # Man or boy test def a(k, x1, x2, x3, x4, x5) b ||= Proc.new { k -= 1; a(k, b, x1, x2, x3, x4) } return k <= 0 ? x4[] + x5[] : b[] end puts a(10, Proc.new {1}, Proc.new {-1}, Proc.new {-1}, Proc.new {1}, Proc.new {0}) -- 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]