Loading

SUBLIST

lists

It creates a new list with the elements of the base list whose indices are in the argument list.

If the argument list contains two indices [a,b] then SUBLIST returns the list of elements from index a to index b (included). If the argument list contains more than two indices, the result of SUBLIST contains all the elements at the specified indices, with possible duplicates.

Negative indexing is allowed, with negative index effectively referring to index + size.

Since 2.1 a new signature allowing the step to be defined has been introduced. Instead of specifying a list has range, you can put the start, end (optional) and step (optional) as LONG values.

SUBLIST is available since version 1.0.0.

Signatures

Examples

// Normal use, with more than two elements in the argument list [ 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' ] [ 0 2 4 -4 -2 ] SUBLIST // Range use, with two elements `[a,b]` with `a <= b` [ 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' ] [ 0 2 ] SUBLIST
[ 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' ] -2 3 -2 SUBLIST
[ 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' ] -3 10000 2 SUBLIST