aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/arrays.nl27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/arrays.nl b/tests/arrays.nl
new file mode 100644
index 00000000..bbe36e42
--- /dev/null
+++ b/tests/arrays.nl
@@ -0,0 +1,27 @@
+>> arr := [10, 20, 30]
+= [10, 20, 30]
+
+>> arr[1]
+= 10
+>> arr[-1]
+= 30
+
+sum := 0
+for x in arr
+ sum += x
+>> sum
+= 60
+
+str := ""
+for i,x in arr
+ str ++= "({i},{x})"
+>> str
+= "(1,10)(2,20)(3,30)"
+
+>> arr2 := [10, 20] ++ [30, 40]
+= [10, 20, 30, 40]
+
+>> arr2 ++= [50, 60]
+>> arr2
+= [10, 20, 30, 40, 50, 60]
+