4 ms·
Right! Isn’t concatenation “++” rather than “+” in Haskell for exactly that reason? So if “sum” is a shortcut for “fold with +”, summing a list of strings woul
by iainmerrick 6y ago
Right! Isn’t concatenation “++” rather than “+” in Haskell for exactly that reason?
So if “sum” is a shortcut for “fold with +”, summing a list of strings wouldn’t make sense.
Python still isn’t as regular as it could be, of course, as it does use “+” for concatenating strings.
I think this can all be justified for ergonomic reasons -- using the simple “+” for strong concatenation is convenient, but “sum” is discouraged for strings because it’s slow.
It would be interesting to see a parallel-universe Python that didn’t allow “+” on strings. I wonder if it would have caught on.
- enriquto 6y agoLiterally any symbol other than "+" would work better for string concatenation. For example, the product, the comma, a dot, a space (but this might require other changes in the language), or heck, even the minus sign!