I'm thinking of this one here:
def count[A](p: A => Boolean): Long
We could also provide these specialized for the various collections we have :)
count(f) = foldMap { if (f(_)) 1 else 0 }
I think we need commutative foldMap, which we could use here and get probably all of the performance wins of a specialized function.
Yes we could define it on UnorderedFoldable :)
Also we might want to consider returning Long to be consistent with size.
+1 to use Long, +1 to put it on UnorderedFoldable.
PS: we do have a commutative foldMap for those following along: UnorderedFoldable.unorderedFoldMap.
Could I take this?
@leusgalvan Sure! Go right ahead :)