Closed
Description
openedon Feb 2, 2017
I took a look at the count
implementation for #20403 (cc @cossio), and was surprised to discover that the current definition is nearly identical to sum
(albeit with a type instability):
function count(pred, itr)
n = 0
for x in itr
n += pred(x)
end
return n
end
For example, count(sqrt, [1,2,3,5])
returns 6.382332347441762.
We could disallow this case entirely, but one possibility would be to make count(f, x)
equivalent to countnz
for non-boolean data. Indeed, I'm not sure why we have both countnz
and count
— couldn't we merge the two functions into a single count
function?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment