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
22
Task/Y-combinator/Ceylon/y-combinator-1.ceylon
Normal file
22
Task/Y-combinator/Ceylon/y-combinator-1.ceylon
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Result(*Args) y1<Result,Args>(
|
||||
Result(*Args)(Result(*Args)) f)
|
||||
given Args satisfies Anything[] {
|
||||
|
||||
class RecursiveFunction(o) {
|
||||
shared Result(*Args)(RecursiveFunction) o;
|
||||
}
|
||||
|
||||
value r = RecursiveFunction((RecursiveFunction w)
|
||||
=> f(flatten((Args args) => w.o(w)(*args))));
|
||||
|
||||
return r.o(r);
|
||||
}
|
||||
|
||||
value factorialY1 = y1((Integer(Integer) fact)(Integer x)
|
||||
=> if (x > 1) then x * fact(x - 1) else 1);
|
||||
|
||||
value fibY1 = y1((Integer(Integer) fib)(Integer x)
|
||||
=> if (x > 2) then fib(x - 1) + fib(x - 2) else 2);
|
||||
|
||||
print(factorialY1(10)); // 3628800
|
||||
print(fibY1(10)); // 110
|
||||
11
Task/Y-combinator/Ceylon/y-combinator-2.ceylon
Normal file
11
Task/Y-combinator/Ceylon/y-combinator-2.ceylon
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Result(*Args) y2<Result,Args>(
|
||||
Result(*Args)(Result(*Args)) f)
|
||||
given Args satisfies Anything[] {
|
||||
|
||||
function r(Anything w) {
|
||||
assert (is Result(*Args)(Anything) w);
|
||||
return f(flatten((Args args) => w(w)(*args)));
|
||||
}
|
||||
|
||||
return r(r);
|
||||
}
|
||||
4
Task/Y-combinator/Ceylon/y-combinator-3.ceylon
Normal file
4
Task/Y-combinator/Ceylon/y-combinator-3.ceylon
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Result(*Args) y3<Result, Args>(
|
||||
Result(*Args)(Result(*Args)) f)
|
||||
given Args satisfies Anything[]
|
||||
=> flatten((Args args) => f(y3(f))(*args));
|
||||
Loading…
Add table
Add a link
Reference in a new issue