"Paul Battley" <pbattley / gmail.com> writes:

> On 25/06/06, Christian Neukirchen <chneukirchen / gmail.com> 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.

Nice to see you doing Haskell... :-)

> 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...

It actually takes a block, but only yields and doesn't map.  It would
take a lot of memory if it had to map in every case---not sure that is
a good reason, though.

> Paul.
-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org