[web-devel] Network.Browser.splitMany - bug?

Henning Thielemann lemming at henning-thielemann.de
Fri Dec 5 02:17:31 EST 2008


I don't know whether this is a bug or a feature:

*Network.Browser> splitMany ',' "abc,def,ghj"
["abc",",def,gh"]


According to the name and the comment "Removes delimiters" I propose:

*Network.Browser> splitMany' ',' "abc,def,ghj"
["abc","def","ghj"]

with

splitMany' :: Eq a => a -> [a] -> [[a]]
splitMany' delim =
    uncurry (:) .
    foldr
       (\c ~(str,rest) ->
          if c==delim
            then ([], str:rest)
            else (c:str, rest))
       ([],[])


More information about the web-devel mailing list