Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
8
Task/Catamorphism/Haskell/catamorphism-1.hs
Normal file
8
Task/Catamorphism/Haskell/catamorphism-1.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
main :: IO ()
|
||||
main =
|
||||
putStrLn . unlines $
|
||||
[ show . foldr (+) 0 -- sum
|
||||
, show . foldr (*) 1 -- product
|
||||
, foldr ((++) . show) "" -- concatenation
|
||||
] <*>
|
||||
[[1 .. 10]]
|
||||
12
Task/Catamorphism/Haskell/catamorphism-2.hs
Normal file
12
Task/Catamorphism/Haskell/catamorphism-2.hs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Data.Monoid
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
let xs = [1 .. 10]
|
||||
in (putStrLn . unlines)
|
||||
[ (show . getSum . foldr (<>) mempty) (Sum <$> xs)
|
||||
, (show . getProduct . foldr (<>) mempty) (Product <$> xs)
|
||||
, (show . foldr (<>) mempty) (show <$> xs)
|
||||
, (show . foldr (<>) mempty) (words
|
||||
"Love is one damned thing after each other")
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue