Pascal's triangle: Difference between revisions
Content added Content deleted
Line 1,452: | Line 1,452: | ||
Or, by creating a scan function: |
Or, by creating a scan function: |
||
{{incomplete|Python|Need to print the rows in the second example}} |
|||
<lang python>def scan(op, seq, it): |
<lang python>def scan(op, seq, it): |
||
a = [] |
a = [] |
||
Line 1,466: | Line 1,465: | ||
return [l+r for l,r in zip(row+[0,],[0,]+row)] |
return [l+r for l,r in zip(row+[0,],[0,]+row)] |
||
return scan(nextrow, range(n), [1,]) |
return scan(nextrow, range(n-1), [1,]) |
||
for row in pascal(4): |
|||
print(row)</lang> |
|||
=={{header|R}}== |
=={{header|R}}== |