Simple Pascal-triangle implementations
-- The first version can output a row of Pascal's triangle : import System.Environment(getArgs) pas 0 = [1] pas n | n>0 = let l = pas (n-1) in zipWith (+) (0:l) (l++[0]) main = do [s] <- getArgs print . pas $ read s -- The second revision can output a certain number of rows of the triangle: import System.Environment(getArgs) pas = iterate nextline [1] where nextline l = zipWith (+) (0:l) (l++[0]) main = do [s] <- getArgs putStr . unlines . map show $ take (read s+1) pas -- And the last monolith solves a very simple homework assignment: import Data.List(intersperse) import System.Environment(getArgs) pas 0 = [1] pas n = let l = pas (n-1) in zipWith (+) (0:l) (l++[0]) strPas s = do let n = read s if n<0 || n>30 then fail ...