blob: 4eb2e6099441b15e842bb558d0452c8c0503986f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* heh, this technically speaking would work but the templating turns out to be
* too much for both GCC and clang. With some manual intervention on the
* generated code I can get fibonacci numbers up to about 35 to work, but then
* I run out of stack space. I guess the compiler can't collapse frames so the
* bifurcating nature of fibonacci just gets mapped to a linear sequence of
* calls? */
fib(int n, (int) res)
{
if n < 2 {
res(1);
} else {
fib(n - 1) => int f1;
fib(n - 2) => int f2;
res(f1 + f2);
}
}
main()
{
fib(6) => int n;
fwd_println(n);
}
|