Steven Huwig wrote:
[...]

1) Did I miss something in the Prelude or standard library that gives
   me this functionality, or something close to it?

[...]

3) The 3-tuple output of unravel looks ugly to me, but I can't think
of an alternative. For the case where there is an equal number of
p-groups and not-p-groups, we need to know which side to start the
zipWith. Does anyone have a better way?


Here's another way to get something similar.

   import Data.Char(isSpace)
   import Data.List(groupBy)

   (op `on` f) x y = f x `op` f y
   wordsAndSpaces  = groupBy ((==) `on` isSpace)

It has a couple of advantages: laziness, and being reversible by good ol' concat.

It's a slight nuisance that you have to use isSpace *again* to get your bearings, if you use wordsAndSpaces in a mapWords function.

Regards,
Tom


_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to