
28 Jul
2004
28 Jul
'04
5:16 a.m.
On 27 July 2004 23:44, ariep@xs4all.nl wrote:
{- | Split the list at the occurrences of a separator into sub-list. This is a generalization of 'words'. -} chop :: (a -> Bool) -> [a] -> [[a]] chop p s = let (l, s') = break p s in l : case s' of [] -> [] (_:rest) -> chop p rest
I like 'chop'. It belongs in Data.List, I'd say.
We have something very like this inside GHC, except we call it 'split'. It's very useful for splitting up file paths into components. For comparison, Perl calls it 'split'. In Perl, 'chop' does something different. Python also has a 'split' function that does something similar. Does anyone object to calling it 'split'? Cheers, Simon