list := []int x := 1 while x <= 1000 { list.append(x) assertEq(list.reduce(fn(tot: int, a: int) -> int { return tot + a }, 0), x*(x + 1)/2) x = x + 1 } fn sum(a: int, b: int) -> int { return a + b } list = []int x = 1 while x <= 100 { list.append(2*x - 1) assertEq(list.reduce(sum, 0), x*x) x = x + 1 } # list concatenation assertEq([1, 2] + [3], [1, 2, 3]) assertEq(["Eny", "meanie"] + ["minie", "moe"], ["Eny", "meanie", "minie", "moe"]) # string splitting assertEq("abcd".split(""), ["a", "b", "c", "d"]) assertEq("the, first, time".split(", "), ["the", "first", "time"]) # list indexing assertEq([1, 2, 3].at(1), 2) assertEq(["a", "b", "c"].at(2), "c")