RosettaCodeData/Task/Pascals-triangle/Haskell/pascals-triangle-5.hs
2023-07-01 13:44:08 -04:00

5 lines
148 B
Haskell

-- generate next row from current row
nextRow row = zipWith (+) ([0] ++ row) (row ++ [0])
-- returns the first n rows
pascal = iterate nextRow [1]