Next: union

Prev: setremove

sublist

sublist(list, start)
sublist(list, start, length)
This function returns a sublist of list beginning at the element numbered by start. If length is specified, then the sublist has that length; otherwise, the length is given by (length(list) - (start - 1)). If start is less than 1, if the length of the sublist is negative, or if the sum of start and length is greater than one more than the length of the list, then sublist() throws a ~range error.

Examples:

sublist([2, 3, 4, 5, 6, 7], 2, 3)
     => [3, 4, 5]
sublist([2, 3, 4, 5, 6, 7], 3)
     => [4, 5, 6, 7]
sublist([2, 3, 4, 5, 6, 7], 7)
     => []