Posted on December 12, 2007 by Tommy McGuireGwern Branwen replied to my announcement of the still-incomplete Software Tools in Haskell on the haskell-cafe mailing list with a neat article describing run-length-decoding, which included a pointer to another article in Don Stewart's blog on Arrows and RLE in Haskell.
Don has the following encoding function:
encode = map (length &&& head) . group
which, of course, implies that computing the average of a list of numbers would be:
uncurry (/) . (sum &&& fromIntegral . length)
Arrows are weird.
(Don't forget to include Control.Arrow, by the way.)