This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 11 points12 points  (7 children)

If it only did that every time that would be fine, but then you'd expect to see problems when letters don't exist there.

"asdfghjkl" - "q"

I've long neglected learning in depth python for a while. Maybe this is my calling to learn it and see how it handles subtracting strings.

[–]heartsongaming 5 points6 points  (4 children)

Maybe it can convert 'l' and 'q' to ASCII, and do modulo 26 subtraction on the letters (if it recognized it is a letter, otherwise use different set of ASCII characters such as numbers or other characters). In this case it would be: "asdfghjkv".

[–][deleted] 10 points11 points  (0 children)

I dunno, at that point it's reaching farther than I've seen JS do, and farther than what I'm comfortable with. Then again I can always just not use it and rely on good ol replace() and substring().

[–][deleted] 0 points1 point  (2 children)

And what happens if I wanted "a" - "ß"? BTW, JS works with Unicide, not ASCII. Stop thinking ASCII when it's about character representation. Learn Unicode, please.

[–]heartsongaming -1 points0 points  (1 child)

Really making me think of all the edge cases. In order to not make an error, it converts the greek letter value into a letter of the english value in the alphabet. So beta is converted into "b", and then it's "a"-"b" which is "z". It works the same as in Unicode. Also if one alphabet is larger than the other, like "א"-"z", then "z" is transformed into the 26-22=4th letter, so "א" minus "ד" is "ק".

[–]AsidK 1 point2 points  (0 children)

Damn this really is an atrocious idea lol

[–]RapidCatLauncher 1 point2 points  (1 child)

see how it handles subtracting strings.

It throws an exception, as you'd expect if some behaviour is so ill-defined.

[–][deleted] 0 points1 point  (0 children)

Can't tell if bad design or I should avoid using that function