diff options
Diffstat (limited to 'test.toc')
-rw-r--r-- | test.toc | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -1,6 +1,27 @@ -#include "std/io.toc", io; +#include "io.toc", io; -main ::= fn() { - foo := new(int, 20); - p := &foo[12]; +arr_sum ::= fn(n::=, t::=, a:[n]t) t { + total := 0 as t; + for x := a { + total += x; + } + total +}; + +mk_arr ::= fn(x:int, y:int, z:int) a:[3]int { + a[0] = x; + a[1] = y; + a[2] = z; }; + +main ::= fn() { + x ::= 3; + #if x > 2 { + io.puts("Hello!"); + } else { + foo("yes"); + } + io.puti(arr_sum(mk_arr(5,89,22))); + io.puti(arr_sum(mk_arr(1,2,3))); + io.puti(arr_sum(mk_arr(z=0, 0, 0))); +};
\ No newline at end of file |