repo.or.cz
/
vox.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
removed slot operator (no longer needed) & class proto bug fix to use NewSlot by...
[vox.git]
/
examples
/
ycombinator.vx
blob
685361944c997830675d7c68747e2e3d9ad8d20a
1
2
/* code 'borrowed' from the spidermonkey distribution (thanks!) */
3
4
function factorial(proc)
5
{
6
return function (n)
7
{
8
return (n <= 1) ? 1 : n * proc(n-1);
9
}
10
}
11
12
function Y(outer)
13
{
14
function inner(proc)
15
{
16
function apply(arg)
17
{
18
return proc(proc)(arg);
19
}
20
return outer(apply);
21
}
22
return inner(inner);
23
}
24
25
println("5! is " + Y(factorial)(5));