[Haskell-cafe] Code Golf
Sebastian Fischer
sebf at informatik.uni-kiel.de
Thu Apr 16 03:42:31 EDT 2009
> 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
More information about the Haskell-Cafe
mailing list