Proposal for generalized function partition in List-library

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
17 May 2001 19:43:46 GMT


17 May 2001 19:36:44 GMT, Marcin 'Qrczak' Kowalczyk <qrczak@knm.org.pl> pisze:

> PS. What I would perhaps put into standard library:

And also:

    split :: (a -> Bool) -> [a] -> [[a]]
    split p c = let
        (xs, ys) = break p c
        in xs : case ys of
            []   -> []
            _:zs -> split p zs

    softSplit :: (a -> Bool) -> [a] -> [[a]]
    -- softSplit p c = filter (not . null) (split p c)
    softSplit p c = case dropWhile p c of
        []   -> []
        x:xs -> let
            (ys, zs) = break p xs
            in (x:ys) : softSplit p zs

It follows that words = softSplit isSpace.
Any better name?

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK