The opposite of
a in b seems to be
!(a in b) which looks clunky to me. I would prefer something like
a not in b, but that doesn’t work.
Seems to me that a general rule would work well:
x not op y ≣ !(x op y)
Is there some way to achieve this?
\notin expands to
∉, such as
a ∉ b.
a in b can be written as
a ∈ b with the mathematical symbol
∈. And the opposite of that,
∉ is available as an operator too, so you can do
a ∉ b for
!(a in b).
∈ can be typed with
\notin<TAB> in the REPL.
Oooh, interesting. I shall give that a try.
It would be helpful if all such operators were “aliased” to normal words that one could type on a keyboard, however. I don’t know about you, but I don’t have a
∉ key on mine
What we need, I feel, is a way to create infix aliases or functions. Something like:
infix notin = ∉
Or even better, the ability to create our own infix operators.
You can type it on a normal keyboard in a Julia REPL or VS Code by typing
\notin and pressing TAB.
The way to do this with infix operators is either
a \notin<tab> b or
!(a in b). But if you’re willing to give up infix, you can use the function form
There are plugins for Atom and for all other popular editors nowadays to do LaTeX-like tab completion of Unicode math symbols.
@stevengj I did not know that! This will come in very handy.
Thank you all for your help.
You can create your own infix operators. I have an example in New features coming in Julia 1.7 [LWN.net].