Wikipedia: Array slicing
Slices are a key data type in Tengo, giving a more powerful interface to sequences than arrays.
fmt := import("fmt")
s := ["a", "b", "c", "d", "e"]
fmt.println("base array: ", s)
l := s[1:3]
fmt.println("sl1: ", l)
l = s[:5]
fmt.println("sl2: ", l)
l = s[2:]
fmt.println("sl3: ", l)
c := append([], s...)
fmt.println("cpy: ", c)
twoD := [
[0],
[1, 2],
[2, 3, 4]
]
fmt.println("2d: ", twoD)
try it
base array: ["a", "b", "c", "d", "e"] sl1: ["b", "c"] sl2: ["a", "b", "c", "d", "e"] sl3: ["c", "d", "e"] cpy: ["a", "b", "c", "d", "e"] 2d: [[0], [1, 2], [2, 3, 4]]