[Haskell-cafe] Code Golf

Sebastian Fischer sebf at informatik.uni-kiel.de
Mon Apr 20 07:48:37 EDT 2009

On Apr 18, 2009, at 2:48 AM, Sjoerd Visscher wrote:

> using Matt Hellige's pointless fun
> http://matt.immute.net/content/pointless-fun
> diag = foldr1 (zipWith (++) $. id ~> ([]:) ~> id)
>     $. map (++ repeat []) ~> takeWhile (not.null)
>     $. (map.map) (:[]) ~> concat

pretty! Those seem to be exactly the combinators that I was looking for.

Unfortunately, I still don't manage to mimic my version that uses  
functional lists and continuations (but no ++) mainly because I'm  
lacking an equivalent of the second line of the above solution which  
allows for the simpler 'zipWith (++)' instead of the merge function.

Anyway, once you know what they mean, Matt's combinators are quite  
useful. Thanks for pointing that out!


More information about the Haskell-Cafe mailing list