(λf.f f) (λf.λn.if (= n 0) 1 (* n (f f (- n 1))))Afterwards, I found on the CLiki Factorial page a Common Lisp translation of the above:
Example: ((λf.f f) (λf.λn.if (= n 0) 1 (* n (f f (- n 1)))) 5)
((lambda (f) #'(lambda (n) (funcall f f n)))This would probably look much better in Scheme, and I am beginning to understand why Scheme is regarded as a "better Lisp" than Lisp.
#'(lambda (f n) (if (= n 0) 1 (* n (funcall f f (- n 1))))))
Just when I was contemplating "porting" the lambda expression to Ruby, here it is... well, almost. Actually, the Y combinator is used here, instead of the U combinator used by Oleg in the above articles. So, here is the true Ruby translation (actually a sample call of it):
p lambda { |f|
f.call(f)
}.call(
lambda { |recurse|
lambda { |n|
if n == 0 then
1
else
n * recurse.call(recurse).call(n-1)
end
}
}).call(5)