Posted on December 12, 2007 by Tommy McGuire
Labels: notation, math, programming language
Gwern 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.)
active directory applied formal logic ashurbanipal authentication books c c++ comics conference continuations coq data structure digital humanities Dijkstra eclipse virgo electronics emacs goodreads haskell http java job Knuth ldap link linux lisp math naming nimrod notation OpenAM osgi parsing pony programming language protocols python quote R random REST ruby rust SAML scala scheme shell software development system administration theory tip toy problems unix vmware yeti
Member of The Internet Defense League
Site proudly generated by Hakyll.