aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-23 13:31:35 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-23 13:31:35 -0500
commit5d654490bee273bcd6afe612100dafac08199218 (patch)
treeae150f3f955faec7affdf841f86b488a73e54327 /tests
parent87bc0cfdbddeb550b7d7959c88088ef9658a5e2d (diff)
Add first test
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]
+