-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
count(itr) to count trues #20403
Labels
collections
Data structures holding multiple items, e.g. sets
Comments
I could do a PR if someone points me to the correct source file. |
You can find out where the method lives with: julia> @which count(isodd, 1:2)
count(pred, itr) in Base at reduce.jl:654 |
This change could be as simple as count(itr) = count(identity, itr) That definition matches what we do with other reduction functions. |
|
stevengj
added a commit
that referenced
this issue
Feb 2, 2017
stevengj
added a commit
that referenced
this issue
Feb 2, 2017
stevengj
added a commit
to stevengj/julia
that referenced
this issue
Feb 3, 2017
…f non-boolean values are encountered
stevengj
added a commit
to stevengj/julia
that referenced
this issue
Feb 3, 2017
…f non-boolean values are encountered (fixes JuliaLang#20404)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be useful to add a method of
count
that takes a single iterable argument of booleans and returns the number oftrue
elements.For example (imagine that the function
iseven
does not exist), I find this:to be more readable than this:
The text was updated successfully, but these errors were encountered: