aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.sloth
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-06-26 18:49:29 -0500
committerCody <cody@codyq.dev>2023-06-26 18:49:29 -0500
commitdaecd330d5719e4a65d5b07f81209f99f423e6a2 (patch)
tree5e2065a0d43932d39333631b60471c2ad96fa4aa /examples/hello.sloth
parent00e423d30edf38a5e57c5c1c52cdb323c62850bc (diff)
downloadsloth-daecd330d5719e4a65d5b07f81209f99f423e6a2.tar.gz
vset, vget & vlen
Diffstat (limited to 'examples/hello.sloth')
-rw-r--r--examples/hello.sloth18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/hello.sloth b/examples/hello.sloth
index f4e6692..db71b01 100644
--- a/examples/hello.sloth
+++ b/examples/hello.sloth
@@ -20,3 +20,21 @@ fn testtwo(list: [Int]) Int {
return x;
}
+fn testthree(list: [Int]) Int {
+ var x: Int = vlen(list);
+ return x;
+}
+
+foreign fn testback(x: Int) Void;
+
+fn testfour(list: [Int]) Int {
+ vseti(list, 0, 888);
+ var i: Int = 0;
+ while i < vlen(list) {
+ var value: Int = vgeti(list, i);
+ testback(value);
+ i = i + 1;
+ }
+ return 0;
+}
+