all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
3
Task/Y-combinator/E/y-combinator-1.e
Normal file
3
Task/Y-combinator/E/y-combinator-1.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def y := fn f { fn x { x(x) }(fn y { f(fn a { y(y)(a) }) }) }
|
||||
def fac := fn f { fn n { if (n<2) {1} else { n*f(n-1) } }}
|
||||
def fib := fn f { fn n { if (n == 0) {0} else if (n == 1) {1} else { f(n-1) + f(n-2) } }}
|
||||
6
Task/Y-combinator/E/y-combinator-2.e
Normal file
6
Task/Y-combinator/E/y-combinator-2.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
? pragma.enable("accumulator")
|
||||
? accum [] for i in 0..!10 { _.with(y(fac)(i)) }
|
||||
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
|
||||
|
||||
? accum [] for i in 0..!10 { _.with(y(fib)(i)) }
|
||||
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
||||
Loading…
Add table
Add a link
Reference in a new issue