[Haskell-cafe] Why is there no "splitSeperator" function inData.List
iustin at google.com
Mon Feb 14 12:48:30 CET 2011
On Sun, Feb 13, 2011 at 11:33:16PM -0800, Donn Cave wrote:
> > 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.
Agreed, but I don't think that lacking a generic split functionality (as
in reversible split) is also good.
More information about the Haskell-Cafe