This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setf Y (lambda (g) | |
(funcall (lambda (f) (lambda (n) (funcall (funcall g (funcall f f)) n))) | |
(lambda (f) (lambda (n) (funcall (funcall g (funcall f f) n))))))) | |
(setf factorial (funcall Y | |
(lambda (f) | |
(lambda (n) | |
(if (< n 2) n | |
(* n (funcall f (- n 1)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Y = function(g) { | |
var recur = function (f) { | |
return function(n) { | |
return g(f(f))(n); | |
}; | |
}; | |
return recur(recur); | |
}; | |
var fact = function(rec) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Y (g): | |
r = lambda f : lambda n : g(f(f))(n) | |
return r(r); | |
def fact (f) : | |
return lambda n : n if n < 2 else n * f(n - 1) | |
factorial = Y(fact) | |
print(factorial(7)) |