27.28 ForAny

ForAny( list, func )

ForAny returns true if the unary function func returns true for at least one element of the list list and false otherwise. list may contain holes. func must return either true or false for every element of list, otherwise ForAny signals an error.

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

ForAll (see ForAll) allows you to test if all elements of a list satisfies a certain propertie.

Previous Up Top Next
Index

GAP 3.4.4
April 1997