PositionSet( list, elm )
PositionSet( list, elm, func )
In the first form PositionSet
returns the position of the element
elm, which may be an object of any type, with respect to the sorted
list list.
In the second form PositionSet
returns the position of the element
elm, which may be an object of any type with respect to the list
list, which must be sorted with respect to func. func must be a
function of two arguments that returns true
if the first argument is
less than the second argument and false
otherwise.
PositionSet
returns pos such that list[pos-1] < elm
and
elm = list[pos]
. That means, if elm appears once in list,
its position is returned. If elm appears several times in list, the
position of the first occurrence is returned. If elm is not an element
of list, then false
is returned.
gap> PositionSet( [1,4,5,5,6,7], 0 ); false gap> PositionSet( [1,4,5,5,6,7], 2 ); false gap> PositionSet( [1,4,5,5,6,7], 4 ); 2 gap> PositionSet( [1,4,5,5,6,7], 5 ); 3 gap> PositionSet( [1,4,5,5,6,7], 8 ); false
PositionSet
is very similar to PositionSorted
(see PositionSorted)
but returns false
when elm is not an element of list.
GAP 3.4.4