aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-07-10 13:34:45 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-07-10 13:34:45 -0400
commit10e86153a2c619d7f853ab149e451a9cc05fdb27 (patch)
treeeded5dc8c1fc50168545f2b40575ebd2b6bf078f /test
parentdf765200c41692eed41c0f84a8b9a32e39f7fa34 (diff)
Replace array:slice() with array:from(first, last) and array:by(step)
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index b609aa9b..9eea9dd9 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -118,3 +118,28 @@ func main():
>> sorted == sorted:sorted()
= yes
+ do:
+ >> [i*10 for i in 5]:from(3)
+ = [30, 40, 50]
+ >> [i*10 for i in 5]:from(last=3)
+ = [10, 20, 30]
+ >> [i*10 for i in 5]:from(last=-2)
+ = [10, 20, 30, 40]
+ >> [i*10 for i in 5]:from(-2)
+ = [40, 50]
+
+ >> [i*10 for i in 5]:by(2)
+ = [10, 30, 50]
+ >> [i*10 for i in 5]:by(-1)
+ = [50, 40, 30, 20, 10]
+
+ >> [10, 20, 30, 40]:by(2)
+ = [10, 30]
+ >> [10, 20, 30, 40]:by(-2)
+ = [40, 20]
+
+ >> [i*10 for i in 10]:by(2):by(2)
+ = [10, 50, 90]
+
+ >> [i*10 for i in 10]:by(2):by(-1)
+ = [90, 70, 50, 30, 10]