Anonymous user
Anonymous recursion: Difference between revisions
→{{header|Qi}}
Line 977:
>>> [ Y(fib)(i) for i in range(-2, 10) ]
[None, None, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]</lang>
=={{header|Qi}}==
Use of anonymous recursive functions is not common in Qi. The philosophy of Qi
seems to be that using a "silly name" like "foo2" or "foo_helper" makes the code clearer than using anonymous recursive functions.
However, it can be done, for instance like this:
<lang Qi>
(define fib
N -> (let A (/. A N
(if (< N 2)
N
(+ (A A (- N 2))
(A A (- N 1)))))
(A A N)))
</lang>
=={{header|R}}==
|