27.27 ForAll

ForAll( list, func )

ForAll returns true if the unary function func returns true for all elements of the list list and false otherwise. list may contain holes. func must return either true or false for every element of list, otherwise an error is signalled.

    gap> ForAll( [1..20], IsPrime );
    false
    gap> ForAll( [2,3,4,5,8,9], IsPrimePowerInt );
    true
    gap> ForAll( [2..14], n -> IsPrimePowerInt(n) or n mod 2 = 0 );
    true 

ForAny (see ForAny) allows you to test if any element of a list satisfies a certain property.

Previous Up Top Next
Index

GAP 3.4.4
April 1997