27.22 Sublist

Sublist( list, inds )

Sublist returns a new list in which the i-th element is the element list[ inds[ i ] ], of the list list. inds must be a list of positive integers without holes, it need, however, not be sorted and may contains duplicate elements. If list[ inds[ i ] ] is unbound for an i, an error is signalled.

    gap> Sublist( [ 2, 3, 5, 7, 11, 13, 17, 19 ], [4..6] );
    [ 7, 11, 13 ]
    gap> Sublist( [ 2, 3, 5, 7, 11, 13, 17, 19 ], [1,7,1,8] );
    [ 2, 17, 2, 19 ] 

The result is a new list, that is not identical to any other list. The elements of that list however are identical to the corresponding elements of the argument list (see Identical Lists).

Filtered (see Filtered) allows you to extract elements from a list according to a predicate.

Sublist has been made obsolete by the introduction of the construct list{ inds } (see List Elements).

Previous Up Top Next
Index

GAP 3.4.4
April 1997