lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi, I just tried

print((function (f,x) return f(f,x) end)(function (f,x) if x>1 then return f(f,x-1)*x else return 1 end end,5))


And was impressed.  This is a rather direct rendition of the functional
teaser "how do I use a recursive function call without permanent
binding" which is solved in Scheme by saying

((lambda(f x) (f f x))(lambda (f x) (if (> x 1) (* (f f (- x 1)) x) 1)) 5)


David Kastrup