# Lambda the Ultimate

 Y Combinator in Ruby started 2/15/2001; 11:02:09 AM - last post 2/20/2001; 8:18:25 AM
 Chris Rathman - Y Combinator in Ruby   2/15/2001; 11:02:09 AM (reads: 2515, responses: 6)
 Y Combinator in Ruby Under the category of recreational computing, Jim Weirich and other CLUG members were discussing Y Combinator implementation in various languages. The example is based upon the factorial function. Among the examples is Ruby, Java, Perl, Scheme, and the Lambda Calculus. Posted to fun by Chris Rathman on 2/15/01; 11:08:15 AM

 andrew cooke - Re: Y Combinator in Ruby   2/15/2001; 11:49:48 AM (reads: 1652, responses: 0)
 ```> y f = f (y f) > y (\f -> (\x -> if x == 0 then 1 else f(x-1))) 3 6 ``` Haskell (maybe it could be shorter if you can do pattern matching in lambdas - but I get syntax errors when I try). Is the first line cheating? (I picked it up here - I'm not that smart (that link explains how to do it without recursion)) PS - It looks like Haskell uses arbitrary precision, but I can't much beyond 3000! before I have a stack overflow. Seems quite quick, though (at least compared to the TI calulator I used at school which took a second or two to do 67!)
 pixel - Re: Y Combinator in Ruby   2/15/2001; 12:24:06 PM (reads: 1660, responses: 0)
 I wonder why the ruby version is so complicated, don't they allow more than one parameter? ```p lambda {|n| lambda {|fact| fact[fact,n] }[ lambda {|ft,k| k == 0 ? 1 : k * ft[ft, k-1] } ] }[5]; ``` As for the java version, i knew you could have kind of anonymous functions, but i need some time to understand it ;)
 Ehud Lamm - Re: Y Combinator in Ruby   2/19/2001; 5:59:31 AM (reads: 1632, responses: 0)
 It might be fun to try and code mutual recusion (even/odd for example). This adds the complexity of handling composite data types implemented using lambda.
 Chris Rathman - Re: Y Combinator in Ruby   2/19/2001; 1:25:20 PM (reads: 1620, responses: 1)
 Last time I got involved in this sort of thing with Jim, I spun off and did an example in some 40 odd languages. Not sure if I'm ready to take on another one just yet. When I get time, I might try to extend the example to show how combinators can be implemented in a number of languages. Y is the more difficult one, so it shouldn't require too much of stretch. Anyhow, I thought the discussion on Y Combinators was interesting. In the meantime, I passed the Sun Java2 Certification today. I usually don't bother with certs, as they seem to be a racket. Still, when you're new to programming or are trying to break out of your current experience, I suppose they can be handy.
 andrew cooke - Re: Y Combinator in Ruby   2/19/2001; 1:35:29 PM (reads: 1702, responses: 0)
 I passed the Sun Java2 Certification today Congratulations! :-)
 Ehud Lamm - Re: Y Combinator in Ruby   2/20/2001; 8:18:25 AM (reads: 1628, responses: 0)
 Anyhow, I thought the discussion on Y Combinators was interesting. In the meantime, I passed the Sun Java2 Certification today. Combinators?! Seems like you are overqualified for most Java programming jobs.