3 ms·
I've taken to defining "@" as the Y combinator, so it looks kind of like a "goto" label for looping, e.g.: (@\fact\n \n==n <= n 0 1 (* n (fact (- n 1)))) (T
by fexl 13y ago
I've taken to defining "@" as the Y combinator, so it looks kind of like a "goto" label for looping, e.g.:
(@\fact\n \n==n <= n 0 1 (* n (fact (- n 1))))
(The \n==n forces an eager evaluation, to avoid building a tower of deferred operations with large n.)
The symbol "fact" is arbitrary, e.g. you could say this instead:
(@\loop\n \n==n <= n 0 1 (* n (loop (- n 1))))
To define a name "fact" for that function, it's:
\fact = (@\loop\n \n==n <= n 0 1 (* n (loop (- n 1))))