Infix for isequal


#1

I find I use isequal a lot, especially for tests, so an infix form would be convenient. I checked the issues, but did not find anything related, thought I would ask here before opening an issue.

I don’t have a strong preference for a particular symbol, but if we restrict to less esoteric LaTeX symbols, ≅ (\cong) is free and already recognized by the REPL.


#2

I’ve thought about this a lot. Since it’s such a core operation, it would be nice to have an ASCII syntax for it. E.g. ~ or ~= or something. One thing to consider is that you’ll want to have corresponding operators for isless and once you go operator with that you’ll want all the analogues of ==, !=, <, >, <= and >=.

Related:


#3

Limited to two character operators and only ASCII7 keys, it is difficult to get analogues of all the comparatives.
Here is one way.

a ~ b ≝ isequal(a,b) , a !~ b ≝ !isequal(a,b)
a ~< b ≝ isless(a,b) and a ~> b ≝ isgreater(a,b)
if using braces is not a parser problem
a ~{ b ≝ islessorequal(a,b) and a ~} b ≝ isgreaterorequal(a,b)
else
a <~ b ≝ islessorequal(a,b) and a >~ b ≝ isgreaterorequal(a,b)

otherwise
a ~ b ≝ isequal(a,b) , a !~ b ≝ !isequal(a,b)
a ~< b ≝ isless(a,b) and a ~> b ≝ isgreater(a,b)
!(a ~< b) ≝ isgte(a,b) and !(a ~> b) ≝ islte(a,b)
is not too bad, though asymmetric in syntax