From 10e86153a2c619d7f853ab149e451a9cc05fdb27 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 10 Jul 2024 13:34:45 -0400 Subject: Replace array:slice() with array:from(first, last) and array:by(step) --- test/arrays.tm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') 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] -- cgit v1.2.3