You are viewing a single comment's thread. Return to all comments →

Pretty much the same thing I did, minus self-recursive definition shenanigans:

pascal = iterate ((++ [1]) . (1:) . (zipWith (+) =<< tail)) [1]

Bases on your solutions and adding a bit of my own, I think this might be the shorstest way to solve this, using just the Prelude:

main=interact$unlines.map (unwords.(map show)).flip take s.read s=[1]:map ((1:).(++[1]).(zipWith (+)=<<tail)) s

I could come up with a shorter one, here is your s function without spaces:

s

s=[1]:map((1:).(++[1]).(zipWith(+)=<<tail))s

which is longer by 5 characters than:

p=[1]:[1:zipWith(+)r t++[1]|r@(_:t)<-p]

## Pascal's Triangle

You are viewing a single comment's thread. Return to all comments →

Pretty much the same thing I did, minus self-recursive definition shenanigans:

Bases on your solutions and adding a bit of my own, I think this might be the shorstest way to solve this, using just the Prelude:

I could come up with a shorter one, here is your

`s`

function without spaces:which is longer by 5 characters than: