Anonymous user
Anonymous recursion: Difference between revisions
no edit summary
(Prune {{incorrect}} tags. Ada, Common Lisp and UNIX Shell are incorrect (because the function is not anonymous), but there seems to be no fix.) |
No edit summary |
||
Line 115:
Output:
<pre>63245986</pre>
=={{header|Ela}}==
Using fix-point combinator:
<lang ela>let fib n | n < 0 = fail "Negative n"
| else = fix (\f n -> if n < 2 then n else f (n-1) + f (n-2)) n</lang>
Function 'fix' is defined in standard Prelude as follows:
<lang ela>let fix f = f (& fix f)</lang>
=={{header|Falcon}}==
|