27.18 PositionProperty

PositionProperty( list, func )

PositionProperty returns the position of the first element in the list list for which the unary function func returns true. list must not contain holes. If func returns false for all elements of list false is returned. func must return true or false for every element of list, otherwise an error is signalled.

    gap> PositionProperty( [10^7..10^8], IsPrime );
    20
    gap> PositionProperty( [10^5..10^6],
    >                      n -> not IsPrime(n) and IsPrimePowerInt(n) );
    490 

First (see First) allows you to extract the first element of a list that satisfies a certain property.

Previous Up Top Next
Index

GAP 3.4.4
April 1997