summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc32
1 files changed, 17 insertions, 15 deletions
diff --git a/test.toc b/test.toc
index 71545c6..48e0e1e 100644
--- a/test.toc
+++ b/test.toc
@@ -13,28 +13,30 @@ putf @= fn(x: float) {
");
};
-foo @= fn() int {
- N := 10;
+sum @= fn(x: []int, n: int) int {
+ p := &x[0];
+ end := &x[n-1];
+ total := 0;
+ while p <= end {
+ total = total + *p;
+ p = p + 1;
+ }
+ total
+};
+
+f @= fn() int {
+ N @= 10;
+
numbers := new(int, N);
i := 0;
while i < N {
numbers[i] = i;
i = i + 1;
}
- numbers[5:7][1] + numbers[2:][0] + numbers[:6][3]
+ sum(numbers, N)
};
main @= fn() {
- N @= 5;
- puti(N);
- x : [foo()]int;
- puti(foo());
- teststr := "Hello!";
- i := 0;
- while i < 5 {
- putch(teststr[i]);
- i = i + 1;
- }
- y:int=5+#C("(1<<3)");
- puti(y);
+ a: [f()]int;
+ puti(f());
};