Skip to content
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

Feature request: {=} alias for issetequal #41428

Open
ParadaCarleton opened this issue Jun 30, 2021 · 9 comments
Open

Feature request: {=} alias for issetequal #41428

ParadaCarleton opened this issue Jun 30, 2021 · 9 comments

Comments

@ParadaCarleton
Copy link
Contributor

ParadaCarleton commented Jun 30, 2021

As title says; issetequal is a bit long to type out and is unintuitive as a comparison operator, since statements like x==y are usually written with infix notation. {=} (or perhaps {==}) should be intuitive, and it saves time when typing. Similarly, x {!==} y and x {≠} y would be great for set inequality. The latter would also be nice performance improvements over the current practice of using !issetequal(), since it allows for short-circuit style evaluation: As soon as the function finds some element of x that is not an element of y, we can stop checking whether any other elements are in x but not y, since we have already proven the two sets are not equal by counterexample.

@oscardssmith
Copy link
Member

Allowing braces as part of an identifier seems like a really bad decision.

@ParadaCarleton
Copy link
Contributor Author

Allowing braces as part of an identifier seems like a really bad decision.

Maybe; what would you propose instead?

@oscardssmith
Copy link
Member

I don't think this should have an ASCII symbol only alias.

@JeffBezanson
Copy link
Member

If there is a standard mathematical symbol for this that's in unicode, we should use that, but I don't think one exists.

@ParadaCarleton
Copy link
Contributor Author

If there is a standard mathematical symbol for this that's in unicode, we should use that, but I don't think one exists.

How about using for equivalence relations in general, and then specifying the desired equivalence relation with a keyword like under? For example, these would return true:

4 ≃ 2 under mod(2)
[1, 2, 3] ≃ [3, 1, 2] under seteq

@StefanKarpinski
Copy link
Member

You can, in your own code, pick a infix Unicode operator and just use it. E.g.:

julia> const  = issetequal
issetequal (generic function with 4 methods)

julia> [1, 2]  [2, 1, 2]
true

This just isn't an operation that gets used enough to need special syntax for it. I do this sometimes when I'm writing code that does a lot of set differences with const \ = setdiff.

@ivaquero
Copy link

ivaquero commented Sep 21, 2021

Hi, @StefanKarpinski, I just tried your method

const= setdiff

However, I got an error message

LoadError: syntax: invalid character "∖" near column 7
syntax: invalid character "∖" near column 7

Stacktrace:
 [1] top-level scope
   @ In[37]:1
 [2] eval
   @ ./boot.jl:360 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1116

How can I fix this ? BTW, I use Julia 1.6.2 in Jupyter. I guess it is a problem of \setminus Unicode because const ≃ = issetequal works.

@cormullion
Copy link
Contributor

Notice the different Unicode values of the two glyphs:

Screenshot 2021-09-22 at 18 09 08

@ivaquero
Copy link

ivaquero commented Sep 22, 2021

I see, thanks. Another question, what caused the \setminus Unicode ocupied ? Why cannot it be used here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants