Pascal's triangle: Difference between revisions
Content deleted Content added
→{{header|Ruby}}: added a two line ruby version |
|||
Line 974:
end</lang>
Or for more or less a translation of the two line Haskell version:
<lang ruby>def next_row row ; ([0] + row).zip(row + [0]).collect {|l,r| l + r }; end
def pascal n ; Array.new([1] * n).inject([1]) {|x,y| y = next_row x } ; end</lang>
=={{header|Scala}}==
Simple recursive row definition:
|