[Haskell-cafe] Is this a useful higher-order function,
or should I RTFM?
tpledger at ihug.co.nz
Mon Dec 6 23:05:03 EST 2004
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.
(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
It's a slight nuisance that you have to use isSpace *again* to get your
bearings, if you use wordsAndSpaces in a mapWords function.
More information about the Haskell-Cafe