tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
10
Task/Catalan-numbers/Haskell/catalan-numbers.hs
Normal file
10
Task/Catalan-numbers/Haskell/catalan-numbers.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- Three infinite lists, corresponding to the three definitions in the problem
|
||||
-- statement.
|
||||
|
||||
cats1 = map (\n -> product [n+2..2*n] `div` product [1..n]) [0..]
|
||||
|
||||
cats2 = 1 : map (\n -> sum $ zipWith (*) (reverse (take n cats2)) cats2) [1..]
|
||||
|
||||
cats3 = scanl (\c n -> c*2*(2*n-1) `div` (n+1)) 1 [1..]
|
||||
|
||||
main = mapM_ (print . take 15) [cats1, cats2, cats3]
|
||||
Loading…
Add table
Add a link
Reference in a new issue