summaryrefslogtreecommitdiff
path: root/tests/misc.toc
blob: 5dcd1eb8b6131450e1e94bae750eddecf32ee0e5 (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
30
31
32
33
34
35
36
37
38
39
40
#include "std/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;
	};
	

	s ::= struct {
		foo, e: int;
		bar ::= 3;
		baz: float;
	}

	p: s;
	p.e = 100;
	io.puti(p["bar"]);
	io.puti(p["e"]);
};