4 ms·
x +- y = (x + x) - (y + y) That's crazy. I should learn Haskell (again).
by cygned 9y ago
x +- y = (x + x) - (y + y)
That's crazy.
I should learn Haskell (again).
- mlevental 9y agowhat exactly is crazy about this?
- runeks 9y agoThe simplicity with which a new operator is defined.
- cygned 9y agoThis. Incredible elegant. I always enjoy these types of things when programming Lisp.
- akhilcacharya 9y agoI think this is a downside. It just makes reading new code that uses esoteric symbols defined elsewhere.
- gilmi 9y agoThis[0] operator glossary reviews the most used operators. [0]: https://haskell-lang.org/tutorial/operators https://haskell-lang.org/tutorial/operators
- Tehnix 9y ago`+-` here is an entirely new operator though. The shuffling of arguments might look a bit weird though, it could also be written (+-) x y = (x + x) - (y + y) Symbol operators are automatically infix though, and you can make them normal using (), same as backticks make normal functions infix, `a la 2 `plus` 3.