Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
29
Task/Y-combinator/Eero/y-combinator.eero
Normal file
29
Task/Y-combinator/Eero/y-combinator.eero
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef int (^Func)(int)
|
||||
typedef Func (^FuncFunc)(Func)
|
||||
typedef Func (^RecursiveFunc)(id) // hide recursive typing behind dynamic typing
|
||||
|
||||
Func fix(FuncFunc f)
|
||||
Func r(RecursiveFunc g)
|
||||
int s(int x)
|
||||
return g(g)(x)
|
||||
return f(s)
|
||||
return r(r)
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
autoreleasepool
|
||||
|
||||
Func almost_fac(Func f)
|
||||
return (int n | return n <= 1 ? 1 : n * f(n - 1))
|
||||
|
||||
Func almost_fib(Func f)
|
||||
return (int n | return n <= 2 ? 1 : f(n - 1) + f(n - 2))
|
||||
|
||||
fib := fix(almost_fib)
|
||||
fac := fix(almost_fac)
|
||||
|
||||
Log('fib(10) = %d', fib(10))
|
||||
Log('fac(10) = %d', fac(10))
|
||||
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue