
16 Apr
2009
16 Apr
'09
3:42 a.m.
ghci> let diag = foldr (curry (prod mappend fst snd . uncurry (coprod mappend (splitAt 2) (splitAt 1)))) []
nice :) thanks to the comments of Martijn and Jan we can replace prod and coprod by liftA2 and <fancy dots>:
let diag = foldr (curry (liftA2 mappend fst snd.uncurry (((flip.). (((.).).).(.)) mappend (splitAt 2) (splitAt 1)))) []
It works for the finite tests but, unfortunately, not for the infinite one :(
take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] *** Exception: stack overflow