3 ms·
APL doesn't do this character arithmetic; BQN does. But it's not weak typing, it's an intentionally designed feature[0]; so things like "a"+1.2 or "a"+"b" error
by dzaima 3y ago
APL doesn't do this character arithmetic; BQN does. But it's not weak typing, it's an intentionally designed feature[0]; so things like "a"+1.2 or "a"+"b" error. It's quite useful too - you can add the null character to a number (or list of numbers) to convert code points to respective characters (or subtract to do the inverse). Or do things like '0'+x to convert a list of numbers to a string of digits (and x-'0' for the inverse); or 'a'+↕26 (↕26 being a list of the numbers 0…25) to generate the alphabet.
(it's the same logic that's behind any language with pointers - you can add a number to a pointer, subtract a number from a pointer, and subtract two pointers to get a number)
[0]: https://mlochbaum.github.io/BQN/doc/arithmetic.html#character-arithmetic https://mlochbaum.github.io/BQN/doc/arithmetic.html#characte...
- ithkuil 3y agoWell said. Your average "very weakly" typed language will happily do "APL"+1 == "APL1"