September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,17 @@
|
|||
1) defining a tail-recursive function:
|
||||
{def fibo {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}}}
|
||||
|
||||
2) testing:
|
||||
{fibo -1} -> the number must be positive!
|
||||
{fibo 0} -> 1
|
||||
{fibo 8} -> 34
|
||||
{fibo 1000} -> 7.0330367711422765e+208
|
||||
{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
|
||||
Loading…
Add table
Add a link
Reference in a new issue