[Haskell-cafe] Why is there no "splitSeperator" function inData.List

Donn Cave donn at avvanta.com
Mon Feb 14 08:33:16 CET 2011


> It is curious though that the Python community managed to agree on a
> single implementation and include that in the standard library

To me, it's more like 2 implementations, overloaded on the same
function name.

Python 2.6.2 (r262:71600, Aug 30 2009, 15:41:32) 
[GCC 2.95.3-haiku-090629] on haiku1
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> string.split(' ho ho ')
['ho', 'ho']
>>> string.split(' ho ho ', ' ')
['', 'ho', 'ho', '']
>>> 

I.e., let the separator parameter default (to whitespace), and you
get what we have with Prelude.words, but specify a split character
and you get a reversible split.  It wasn't a new idea, the Bourne
shell for example has a similar dual semantics depending on whether
the separator is white space or not.  Somehow doesn't seem right
for Haskell, though.

	Donn Cave



More information about the Haskell-Cafe mailing list