Skip to content

count(itr) to count trues #20403

Closed
Closed
@cossio

Description

I think it would be useful to add a method of count that takes a single iterable argument of booleans and returns the number of true elements.

For example (imagine that the function iseven does not exist), I find this:

count(i % 2 == 0 for i in 1:10)

to be more readable than this:

count(i -> i % 2 == 0, 1:10)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. sets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions