summaryrefslogtreecommitdiff
path: root/tests/misc.toc
blob: a9f6dc1ed9b8b88da97563682a6ab45f4669174b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "io.toc", io;

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)));
	 
	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;
	};

};