summaryrefslogtreecommitdiff
path: root/Loops/loops.b
diff options
context:
space:
mode:
authorhenesy <henesy.dev@gmail.com>2019-02-26 10:39:13 -0600
committerhenesy <henesy.dev@gmail.com>2019-02-26 10:39:13 -0600
commit9611c053041139ed398a9153877c42968caf4dfe (patch)
tree7ca1ec1289d8da6598a1a85d52feba1c75bf96c0 /Loops/loops.b
parentdbf76bdbadd4ef4cd3de22b613d4c7f8492bb840 (diff)
add Loops
Diffstat (limited to 'Loops/loops.b')
-rw-r--r--Loops/loops.b39
1 files changed, 39 insertions, 0 deletions
diff --git a/Loops/loops.b b/Loops/loops.b
new file mode 100644
index 0000000..a129e6f
--- /dev/null
+++ b/Loops/loops.b
@@ -0,0 +1,39 @@
+implement Loops;
+
+include "sys.m";
+include "draw.m";
+
+sys: Sys;
+print: import sys;
+
+Loops: module {
+ init: fn(nil: ref Draw->Context, nil: list of string);
+};
+
+init(nil: ref Draw->Context, nil: list of string) {
+ sys = load Sys Sys->PATH;
+
+ print("== for\n");
+
+ for(i := 0; i < 10; i++){
+ if(i % 2 == 0)
+ continue;
+
+ print("%d\n", i * i);
+ }
+
+ print("== while\n");
+
+ n := 7;
+ while(n)
+ print("%d\n", n--);
+
+ print("== do\n");
+
+ do{
+ print("%d\n", ++n);
+ break;
+ }while(1);
+
+ exit;
+}