Jump to content

Anonymous recursion: Difference between revisions

(Added 11l)
Line 1,292:
{map fibo {serie 1 20}}
-> 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946
 
We could also avoid any name and write an IIFE
 
{{lambda {:n}
{{lambda {:f :n :a :b} {:f :f :n :a :b}}
{lambda {:f :n :a :b}
{if {< :n 0}
then the number must be positive!
else {if {< :n 1}
then :a
else {:f :f {- :n 1} {+ :a :b} :a}}}} :n 1 0}}
8}
-> 34
 
</lang>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.