Pascal's triangle: Difference between revisions

→‎{{header|Perl 6}}: edit for style, remove superstitious parens
(→‎{{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:
 
{{trans|Perl}}
<lang perl6>sub pascal ($n where $n >= 1) {
# Prints out $n rows of Pascal's triangle.
{$n <say 1my and@last return= Mu1;
for (1 .. $n - 1) -> $row {
say "1";
{ my @this = map (->{ $a {@last[$a_] + @last[$a_ + 1] }), 0 .. $row - 2;
$n == 1 and return 1;
my 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 ===
Anonymous user