Talk:Multiplication tables: Difference between revisions
→Perl 6 Multiplication Table Output glitch
Line 23:
Anyone else see a problem with the dashes on the Perl-6 entry? --[[User:Paddy3118|Paddy3118]] 18:44, 27 August 2010 (UTC)
I do not have a working copy of perl 6, so I can not test this change, but I would suggest:
<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), '│ ', (
for 1..$max -> $j {
$i <= $j ?? $i*$j !! '';
}
).fmt($f);
}</lang>
|