List Incomprehensions

by chromatic

I'm working my way through Graham Hutton's Programming in Haskell. Despite the fact that I'm not a mathematician (and I still believe that Haskell has syntax only a mathematician could love), it's an accessible computer science text. It's nicely clear, too, despite its relatively short length.

Most of the exercises are good too... except for one stumper in the list comprehensions chapter.


2 Comments

Matthias Hertel
2007-04-13 04:44:13
I haven't read Hutton's book, but as introductions to Haskell go, I think the point of this exercise was not to present a particularly beautiful alternative way of expressing this computation.
Rather, converting a list comprehension to the equivalent concat/map expressions can enable further program transformations (eg, fusion with a neighboring fold), so it is a good thing to be able to do by hand.
David Tran
2008-01-04 14:15:11
Here is my solution:
http://davidtran.doublegifts.com/blog/?p=119