diff options
Diffstat (limited to 'test.toc')
-rw-r--r-- | test.toc | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -9,15 +9,26 @@ putf @= fn(x: float) { "); }; -lsh @= fn(x: int, bits: int) int { - each 1..bits { - x *= 2; +sum @= fn(x: []int) int { + total := 0; + p := &x[0]; + while p < &x[0] + x.len { + total += *p; + p += 1; + } + total +}; + +some_sum @= fn() int { + foo := new(int, 10); + each _, i := foo { + foo[i] = i; } - x + sum(foo) }; main @= fn() { - puti(lsh(2, 15)); - X @= lsh(2, 15); + puti(some_sum()); + X @= some_sum(); puti(X); }; |