This is one with functional lists:

diag = foldr1 (zipWith (.) $. id ~> (id:) ~> id)
     $. map (++ repeat id) ~> takeWhile (not.null.($[]))
     $. (map.map) (:) ~> ($[]) . mconcat

On Apr 20, 2009, at 1:48 PM, Sebastian Fischer wrote:


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!

Cheers,
Sebastian
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

--
Sjoerd Visscher
[email protected]



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to