Language: Slices
Slices are an efficient way to create a substring or sublist from an existing string or list, respectively.
The syntax for creating a slice is:
low
is the lowest index to slice from. The resulting slice includes
the value at low
. high
is the index to slice to. The resulting slice
will not include the value at high
. The length of the resulting list
or string is always high - low
.
Convenience Shorthands
Some convenience shorthands are available by omitting the value for either the
low or high index in the slice expression: omitting low
implies a low index of
0, and omitting high
implies a high index of the length of the list.