summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-16 16:26:13 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-16 16:26:13 -0400
commitb7b3e0868b9eef1018f87bd1c81c0112abaf94f4 (patch)
treee9a754e867302b9949612fec639b7722967f94fc /test.toc
parent35459f4ef5c9076a331acecd0c16328326c4081b (diff)
break, continue
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc20
1 files changed, 17 insertions, 3 deletions
diff --git a/test.toc b/test.toc
index 8103f08..9c9d467 100644
--- a/test.toc
+++ b/test.toc
@@ -1,17 +1,31 @@
#include "std/io.toc", io;
-main ::= fn() {
+f ::= fn() int {
+ total := 0;
for i := 1..10 {
if i % 2 == 0 { continue; }
- io.puti(i);
+ total += i;
if i == 7 { break; }
}
i := 0;
while {
i += 1;
- io.puti(i);
+ total += i;
if i == 10 {
break;
}
}
+ while i < 100 {
+ i += 1;
+ if i == 100 {
+ return total;
+ }
+ }
+ 0
}
+
+main ::= fn() {
+ x ::= f();
+ io.puti(x);
+ io.puti(f());
+} \ No newline at end of file