Pascal's triangle: Difference between revisions

no edit summary
m (Fixed lang tags.)
No edit summary
Line 782:
end</lang>
=={{header|Scala}}==
 
Simple (and slow) recursive implementation:
<lang scala>
def tri(rows:Int):List[Int] = { rows match {
case 1 => List(1)
case n:Int => List(1) ::: ((tri(n-1) zip tri(n-1).tail) map {case (a,b) => a+b}) ::: List(1)
}
}
</lang>
Example usage with pretty printing:
<lang scala>
val r=5
(1 to r) foreach {n=>print(" "*(r-n)); tri(n) map (c=>print(c+" ")); println}
</lang>
Outputs:
<pre>
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
</pre>
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";