/
generator.p6
42 lines (33 loc) · 944 Bytes
/
generator.p6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env perl6
use Terminal::Table::Style;
use Terminal::Table::Generator;
my $gl = Generator.new(
style => Style.new(
corner-style => Style::Corner.double(),
line-style => Style::Line.double(),
content-style=> Style::Content.space(),
)
);
for 1 .. 9 -> \x {
for 1 .. x -> \y {
$gl.add-cell("{y} x {x} = {x * y}");
}
$gl.end-line();
}
my $gr = Generator.new(
style => Style.new(
corner-style => Style::Corner.single(),
line-style => Style::Line.dot(),
content-style=> Style::Content.space(),
)
);
my @data;
for reverse 1 .. 9 -> \x {
@data.push([ "{.Int} x {x} = {x * .Int}" for 1 .. x ]);
}
$gr.from-array(@data);
$gl.join($gr, :replace-style);
my $g = $gl.generator().generate();
$g.colour(8, $_, Color::String.new(color => <red bold> )) for ^9;
$g.colour(9, $_, Color::String.new(color => <green bold> )) for ^9;
$g.print(:coloured);