Pascal's triangle: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: no need to list both niecza and rakudo; use Z instead of hyper)
(→‎{{header|Perl 6}}: edit for style, remove superstitious parens)
Line 1,555: Line 1,555:


{{trans|Perl}}
{{trans|Perl}}
<lang perl6>sub pascal ($n)
<lang perl6>sub pascal ($n where $n >= 1) {
# Prints out $n rows of Pascal's triangle.
# Prints out $n rows of Pascal's triangle.
{$n < 1 and return Mu;
say my @last = 1;
for 1 .. $n - 1 -> $row {
say "1";
my @this = map { @last[$_] + @last[$_ + 1] }, 0 .. $row - 2;
$n == 1 and return 1;
my @last = [1];
say @last = 1, @this, 1;
}
for (1 .. $n - 1) -> $row
}</lang>
{my @this = map (-> $a {@last[$a] + @last[$a + 1]}), 0 .. $row - 2;
@last = (1, @this, 1);
say join(' ', @last) ;}
return 1;}
</lang>


=== one-liner ===
=== one-liner ===