
17 Apr
2009
17 Apr
'09
8:48 p.m.
Hi, This one works for all 3 examples you gave: diag = concat . takeWhile (not.null) . foldr1 (flip $ zipWith (flip (++)) . ([]:)) . map ((++ repeat []) . map (:[])) or, 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 I think the second one is quite readable, thanks to Matt's notation. The essential part is up front, and the pre- and post-transformations that belong to each other can be grouped. greetings, -- Sjoerd Visscher sjoerd@w3future.com