Does there exist a generalized version of the `words' function i. e.
one that breaks an arbitrary list into parts by an arbitrary predicate?

splitAt is not what I need.

I had to write my own:

-- A version of words, but works with any lists on any predicate.

parts pred s = case dropWhile pred s of
                                     [] -> []
                                     s' -> w : parts pred s''
                                         where (w, s'') = break pred s'

(just by parameterizing `words' found in Data.List with a predicate passed as a parameter).

In case such a function already exists, what is its name?

In the opposite case, can such a function be added to the standard library? (or why didn't it exist?)

Dimitry Golubovsky
Middletown, CT

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to