[Haskell-cafe] splitting strings
tphyahoo at gmail.com
Thu Mar 1 12:23:46 EST 2007
I think you want
or something very much like it.
2007/3/1, h. <h._h._h._ at hotmail.com>:
> I wrote the following split function for Strings:
> splitS :: String -> String -> [String]
> splitS a b = splitA a b
> z = length b - 1
> splitA  _ = [""]
> splitA (c:cs) (d:ds) | c == d && fst s == ds = "" : splitA (snd s) b
> | otherwise = (c : head r) : tail r
> r = splitA cs b
> s = splitAt z cs
> example: splitS "Test;Hello;+123.5;+ 7" ";+" -> ["Test;Hallo","123.5"," 7"]
> How could it be optimized on speed?
> Does there exist already an optimized split for the conventional String
> Thanks in advance for your answer.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe