next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: number

number -- count how many elements of a list satisfy a condition

Synopsis

Description

i1 : number(0..100, isPrime)

o1 = 25
i2 : number(0..100, odd)

o2 = 50
i3 : number(0..100, i -> i==17)

o3 = 1

To find the first or last index of an element satisfying the condition, see position. For all indices that match the condition, see positions. To return the elements, rather than their indices, see select.

i4 : position((10,20,43,105,6), odd)

o4 = 2
i5 : positions((10,20,43,105,6), odd)

o5 = {2, 3}

o5 : List
i6 : select((10,20,43,105,6), odd)

o6 = (43, 105)

o6 : Sequence

See also