next up previous contents index
suivant: Count the elements equal monter: Arithmetic and matrix précédent: Append a column to   Table des matières   Index


Count the elements of a matrix verifying a property : count

count takes as arguments : a real function f and a real matrix A of dimension p*q (resp a list l of size n).
count returns f(A[0,0])+..f(A[p-1,q-1]) (resp f(l[0])+..f(l[n-1]))
Hence, if f is a boolean function, count returns the number of elements of the matrix A (resp the list l) verifying the property f.
Input :
count(x->x,[[2,12],[45,3],[7,78]])
Output :
147
indeed: 2+12+45+3+7+78=147.
Input :
count(x->x<10,[[2,12],[45,3],[7,78]])
Output :
3



giac documentation written by Renée De Graeve and Bernard Parisse