Y combinator in mitscheme (define Y
(lambda (f)
(let ((g (lambda (h)
(f (lambda (x)
((f (h h)) x))))))
(g g))))
Y combinator in Arc (def Y
(fn (f)
(let g (fn (h)
(f [(f (h h)) _]))
(g g))))
The shortest working definition of Y I can think of. It makes use of
Arc's bracketed anonymous functions of a single argument. These types
of bracketed anonymous functions of one argument cannot be nested as
they all bind their argument to the underscore.What if they could be nested? Maybe the outermost function would bind
its argument to @0, and subsequently nested functions would bind their
arguments to unique variables by incrementing the integer (@0, @1, @2,
...). Then we could write Y quite compactly like this. (def Y [let g [@0 [(@0 (@1 @1)) @2]] (g g)])
