2 ms·
See also: the tadpole operator (https://devblogs.microsoft.com/oldnewthing/20150525-00/?p=45044 https://devblogs.microsoft.com/oldnewthing/20150525-00/?p=45...)
by jeroenhd 3y ago
See also: the tadpole operator (https://devblogs.microsoft.com/oldnewthing/20150525-00/?p=45044 https://devblogs.microsoft.com/oldnewthing/20150525-00/?p=45...)
Returns x+1 or x-1 depending on the direction the tadpole swims (-~x to increment x and or ~-x to decrement x). For a short moment I believed this was a real thing, because my programming font has a special ligature for ~- and -~.
- omoikane 3y agoIt's actually useful in a code golf context, because "x * -~y" is two characters shorter than "x * (y + 1)".
- layer8 3y agoNote that "increment" and "decrement" normally refer to changing the value of a variable (what ++ and -- do). It would have been funny if C had defined -~= and ~-= as the increment and decrement operators.
- jeroenhd 3y agoFair enough. I suppose you would need to write something like `x=~-x` to actually perform an increment on the variable.