Jump to content

Multiplication tables: Difference between revisions

m
→‎{{header|Raku}}: condense code layout
No edit summary
m (→‎{{header|Raku}}: condense code layout)
Line 6,058:
=={{header|Raku}}==
(formerly Perl 6)
<lang perl6>(my $f = "%{$_}s" given my $width = ($_**2).chars ) given my $max = 12;
{{trans|Perl}}
 
say 'x×'.fmt($f), ~ ' ', ~ (1..$max).fmt($f);
{{works with|Rakudo Star|2010.08}}
say '' x $width, ~ '━╋', ~ '' x $max*$width +× (1+$maxwidth);
 
<lang perl6>my $max = 12;
my $width = chars $max**2;
my $f = "%{$width}s";
say 'x'.fmt($f), '│ ', (1..$max).fmt($f);
say '─' x $width, '┼', '─' x $max*$width + $max;
for 1..$max -> $i {
say $i.fmt($f), ~ ' ', ~ ( $i ≤ $_ ?? $i×$_ !! '' for 1..$max ).fmt($f);
for 1..$max -> $j {
$i <= $j ?? $i*$j !! '';
}
).fmt($f);
}</lang>
 
{{out}}
<pre>
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.