Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Anonymous-recursion/OCaml/anonymous-recursion-1.ocaml
Normal file
10
Task/Anonymous-recursion/OCaml/anonymous-recursion-1.ocaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let fib n =
|
||||
let rec real = function
|
||||
0 -> 1
|
||||
| 1 -> 1
|
||||
| n -> real (n-1) + real (n-2)
|
||||
in
|
||||
if n < 0 then
|
||||
None
|
||||
else
|
||||
Some (real n)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
let rec fix f x = f (fix f) x
|
||||
|
||||
let fib n =
|
||||
if n < 0 then
|
||||
None
|
||||
else
|
||||
Some (fix (fun f -> fun n -> if n <= 1 then 1 else f (n-1) + f (n-2)) n)
|
||||
Loading…
Add table
Add a link
Reference in a new issue