1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | {-# OPTIONS_GHC -F -pgmF she #-} import Control.Applicative pascalsNextLine old = 1 <& (| tail' old + init' old |) &> 1 pascalsTriangle = iterate pascalsNextLine (ZipList [1]) -- ziplist helpers instance Show a => Show (ZipList a) where show (ZipList xs) = show xs ala f = ZipList . f . getZipList init' = ala init tail' = ala tail x <& (ZipList xs) = ZipList (x:xs) (ZipList xs) &> x = ZipList (xs ++ [x]) |