summaryrefslogtreecommitdiff
path: root/tests/new.toc
blob: 790a1151e130891bca99b1a669de3a7a34152172 (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
#include "std/mem.toc", mem;
#include "std/io.toc", io;

calculation ::= fn() int {
	total := 0;
	i := mem.new(int);
	*i = 3;
	ns := mem.news(int, 10);
	for n, i := &ns {
		if i % 2 == 0 {
			*n = i;
		}
	}
	for n := ns {
		total += n;
	}
	total += *i;
	mem.del(i);
	mem.dels(ns);
	total
}

main ::= fn() {
	 io.puti(calculation());
	 x ::= calculation();
	 io.puti(x);
}