Adding split/split' to Data.List, and redefining words/lines with it; also, adding replace/replaceBy

Curt Sampson cjs at starling-software.com
Mon Jul 21 00:49:51 EDT 2008


On 2008-07-10 19:40 -0700 (Thu), Eric Torreborre wrote:

> Neil's version of split is has the same kind of behavior than Java's,
> Ruby's, Python's where the separator is not included in the splitted
> list....

Actually, I seem to recall there was something in Ruby somewhere that
did a split-type thing, but gave you the option of including the
delimiter or not. But it's not in String#split, anyway.

Ruby also has special behaviour for including or not including empty
fields at the beginning or end. E.g.:

    "1,2,,3,4,,".split(',', 4)      #=> ["1", "2", "", "3,4,,"]
    "1,2,,3,4,,".split(',', -4)     #=> ["1", "2", "", "3", "4", "", ""]

> I guess that should be possible to include a commonly used version
> of split in the standard libraries then, even if it is the "Haskell
> version" of split.

Or perhaps we could find some way of specifying how the split is
supposed to work.

cjs
-- 
Curt Sampson       <cjs at starling-software.com>        +81 90 7737 2974   
Mobile sites and software consulting: http://www.starling-software.com


More information about the Libraries mailing list