summaryrefslogtreecommitdiff
path: root/tests/new.toc
blob: 8535a5eff28239e27c7459874214942e6d41c868 (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);
	return total;
}

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