June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
18
Task/Y-combinator/Kitten/y-combinator.kitten
Normal file
18
Task/Y-combinator/Kitten/y-combinator.kitten
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
define y<S..., T...> (S..., (S..., (S... -> T...) -> T...) -> T...):
|
||||
-> f; { f y } f call
|
||||
|
||||
define fac (Int32, (Int32 -> Int32) -> Int32):
|
||||
-> x, rec;
|
||||
if (x <= 1) { 1 } else { (x - 1) rec call * x }
|
||||
|
||||
define fib (Int32, (Int32 -> Int32) -> Int32):
|
||||
-> x, rec;
|
||||
if (x <= 2):
|
||||
1
|
||||
else:
|
||||
(x - 1) rec call -> a;
|
||||
(x - 2) rec call -> b;
|
||||
a + b
|
||||
|
||||
5 \fac y say // 120
|
||||
10 \fib y say // 55
|
||||
Loading…
Add table
Add a link
Reference in a new issue