Catamorphism: Difference between revisions

m
(→‎{{header|Haskell}}: added type signatures, consistent treatment of three cases, output)
m (→‎{{header|Haskell}}: ( spacing ))
Line 702:
=={{header|Haskell}}==
<lang haskell>xs :: [Int]
xs = [1 .. 10]
 
main :: IO ()
main =
mapM_
putStrLnprint
[ show $ foldr (+) 0 xs 0 xs -- sum
, show $ foldr (*) 1 xs 1 xs -- product
, foldr ((++) . show) [ ] xs -- concatenation
]</lang>
{{Out}}
9,655

edits