ok here is one
pairSum :: Num a => [a] -> [a]
pairSum [] = []
pairSum [x] = []
pairSum (x:y:[]) = [x + y]
pairSum (x:y:xs) = x + y : pairSum (y:xs)
pascal :: Integer -> [Integer]
pascal 0 = [1]
pascal x = [1] ++ (pairSum $ pascal (x - 1)) ++ [1]
main = mapM (print . pascal) [0..20]
I don’t think pairSum (x:y:[])
needs to be defined separately, since:
pairSum (x:y:[])
x + y : pairSum (y:[])
x + y : pairSum [y]
x + y : []
[x + y]