[Haskell-cafe] List comparisons and permutation group code

David House dmhouse at gmail.com
Sat Oct 21 09:33:12 EDT 2006

On 21/10/06, Tomasz Zielonka <tomasz.zielonka at gmail.com> wrote:
> Do you also have this experience with Haskell?: when you feel that
> some code is not ideal, almost always it can be improved.

One of the recurring features of the #haskell IRC conversations is
something called 'Algorithm Golf' (which is a misnomer and should
really be 'Algorithm Tennis'): one person will request an algorithm
and anyone interested sets about building their own. The results are
then shared using lambdabot's Haskell evaluation feature and
collaboratively improved.

Aside from leading to efficient and natural-looking solutions to
people's problems, the rounds are often pedagogical and great fun!
Silly spin-offs are also common, leading to such wiki pages as
http://haskell.org/haskellwiki/Compose. That particular example was
mostly my doing and answers the question 'Can you build a function
compose :: [a -> a] -> a -> a, such that a value will be fed into the
top of the list and we'll get a result out of the bottom?'. Of course,
the sane solution is foldl (flip (.)) id, but after noticing that the
State monad permits a particularly elegant solution, execState . mapM
modify, the task evolved into 'In how many other monads can we write
this function?' The examples get more and more silly until we reach
Cont when things disappear off the proverbial horizon into the land of
'How on Earth did Cale ever think of that?'.

I'd recommend hanging out in the channel to anyone. :)

-David House, dmhouse at gmail.com

More information about the Haskell-Cafe mailing list