Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » number
next | previous | forward | backward | up | index | toc

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

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

For the programmer

The object number is a function closure.


The source of this document is in Macaulay2Doc/functions/number-doc.m2:43:0.