Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
1) defining a quasi-recursive function combined with a simple Ω-combinator:
|
||||
{def fibo {lambda {:n}
|
||||
{{{lambda {:f} {:f :f}}
|
||||
{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}}}
|
||||
-> fibo
|
||||
|
||||
2) testing:
|
||||
{fibo -1} -> the number must be positive!
|
||||
{fibo 0} -> 1
|
||||
{fibo 8} -> 34
|
||||
{fibo 1000} -> 7.0330367711422765e+208
|
||||
{S.map fibo {S.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} {:f :f}}
|
||||
{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
|
||||
Loading…
Add table
Add a link
Reference in a new issue