[Haskell-cafe] Re: Why is there no splitBy in the list module?
maeder at tzi.de
Mon Jul 10 08:26:23 EDT 2006
Simon Marlow schrieb:
> Donald Bruce Stewart wrote:
>> Hacking up your own custom split (or a tokens/splitOnGlue) must be one
>> of the most common questions from beginners on the irc channel.
>> Anyone rememeber what the result of the "let's get split into the base
>> library" movement's work was?
> ISTR there wasn't a concensus, so nothing happened. Which is silly,
> really - I agree we should definitely have a Data.List.split.
Maybe someone can extract a result from the old discussion about
"Prelude function suggestions"
Our current (special) version is:
A function inspired by the perl function split. A list is splitted
on a seperator element in smaller non-empty lists.
The seperator element is dropped from the resulting list.
splitOn :: Eq a => a -- ^ seperator
-> [a] -- ^ list to split
splitOn x xs = let (l, r) = break (==x) xs in
(if null l then  else [l]) ++ (if null r then  else splitOn x $
More information about the Haskell-Cafe