Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Y-combinator/GAP/y-combinator.gap
Normal file
35
Task/Y-combinator/GAP/y-combinator.gap
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
Y := function(f)
|
||||
local u;
|
||||
u := x -> x(x);
|
||||
return u(y -> f(a -> y(y)(a)));
|
||||
end;
|
||||
|
||||
fib := function(f)
|
||||
local u;
|
||||
u := function(n)
|
||||
if n < 2 then
|
||||
return n;
|
||||
else
|
||||
return f(n-1) + f(n-2);
|
||||
fi;
|
||||
end;
|
||||
return u;
|
||||
end;
|
||||
|
||||
Y(fib)(10);
|
||||
# 55
|
||||
|
||||
fac := function(f)
|
||||
local u;
|
||||
u := function(n)
|
||||
if n < 2 then
|
||||
return 1;
|
||||
else
|
||||
return n*f(n-1);
|
||||
fi;
|
||||
end;
|
||||
return u;
|
||||
end;
|
||||
|
||||
Y(fac)(8);
|
||||
# 40320
|
||||
Loading…
Add table
Add a link
Reference in a new issue