From: Paul Battley Date: 2006-06-27T03:11:07+09:00 Subject: Re: [QUIZ] pp Pascal (#84) On 25/06/06, Christian Neukirchen wrote: > Given this, I can't resist but "break the rules" even further---by not > even writing the solution in Ruby. ;-) It's pretty nice to do in Haskell: > > > pascal = iterate (\last -> zipWith (+) ([0] ++ last) (last ++ [0])) [1] > > > > pp n = mapM_ (putStrLn . join "|" . map (show)) $ take n $ pascal > > where join s (x:xs) | xs == [] = x > > | otherwise = x ++ s ++ join s xs > > Aha! I had a go at it in Haskell, too, and used the same zipWith technique. Actually, that got me thinking: why doesn't zip in Ruby take a block? It could handle Haskell's zip (and zip3 etc.) *and* zipWith then... Paul.