RosettaCodeData/Task/Pascals-triangle/Haskell/pascals-triangle-5.hs

6 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]