Is there a better way to count the number of elements for which the predicate function is true, other than this:
PredCount[lst_, pred_] := Length@Select[lst, pred];
I ask because it is not possible to build a subset of lstc Select[], but because it Count[]only works with templates. In my case, the function PredCountis called many times with a large one lst.
source
share