Skip to content

Element-wise in operator #5212

@nalimilan

Description

@nalimilan

This occurred to me while reading mbauman@d83dad3:

to select elements of ``A`` equal to 1 or 2 use ``(A .== 1) | (A .== 2)``).

What do you think about having an element-wise in operator? Despite not having a dedicated symbol, I think in is a true operator, and it's the only one without an element-wise version.

This would allow writing e.g. A .in (1, 2) instead of the convoluted form above (and thus reduce priority mistakes). It's very useful when working with data where you often need to test for equality against a longer series of values; or simply when testing for equality against a set of values stored in a variable.

I grant you .in looks a little weird, but not more than .!=. ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions