Skip to content

Alias choose on Seq as flatMap (or flat_map or flatmap) #231

Open
@vreuter

Description

@vreuter

IMO, "choose" sounds more like "filter", and I'd expect the argument to be a function like Callable[[A], bool]when dealing with a Seq[A], which then gives back the elements which satisfied the predicate. Or even some sort of randomised element selector. But what's really happening is each element in the collection is being mapped to an optional according to the passed function, and then the result is "flattened" back by collapsing down those wrapped structures to the original values, while discarding the empty values. One of the "flat map" variants thus feels more intuitive as a name, at least having it as an alias for the choose member of Seq. This would also match this pair of naming and behavior from e.g. Scala collections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions