On Mon, Jul 10, 2006 at 02:26:23PM +0200, Christian Maeder wrote: > 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 > -> [[a]] > splitOn x xs = let (l, r) = break (==x) xs in > (if null l then [] else [l]) ++ (if null r then [] else splitOn x $ > tail r)
just a note: I find splitBy a much nicer routine to provide. > splitBy :: (a -> Bool) -- ^ whether char is a seperator > -> [a] -- ^ list to split > -> [[a]] John -- John Meacham - ⑆repetae.net⑆john⑈ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe