I try to print Pascal's triangle to some arbitrary line after I thought I came up with this solution:
next xs = zipWith (+) ([0] ++ xs) (xs ++ [0]) pascal n = take n (iterate next [1]) main = do n <- readLn :: IO Int mapM_ putStrLn $ map show $ pascal n
Which works well besides printing. When I use pascal 4 , I get:
[1] [1,1] [1,2,1] [1,3,3,1]
When I really want this:
1 1 1 1 2 1 1 3 3 1
Can I do this?
source share