use 5.014;
use utf8;
-use List::Util qw( pairs sum );
+use List::Util qw( pairs pairmap sum );
my %C = qw(red #EC1C24 blue #3953A3 yellow #F9EC31 black #231F20);
my $U = 0; # optional unicode alternatives
sub disptap {
- return map {
- !m/\A(-?)(\d)(\d)/ ? $_ :
- $1.join(' ',
- '·' x $2, '·' x $3,
- );
- } @_;
+ my $code = shift;
+ $code =~ m/\A(-?)(\d)(\d)/ or return $code;
+ return $1 . join(' ', '·' x $2, '·' x $3);
}
sub dispbar {
- my @cols = split //, shift; # bar and space widths
+ my $code = shift;
+
+ return join '', pairmap {
+ ($a =~ tr/123/❘❙❚/r) . ($b =~ tr/321/ /dr)
+ } split //, $code if $U;
+
+ my @cols = split //, $code; # bar and space widths
my $width = sum(@cols);
return sprintf(
'<svg width="%d" height="%d" viewBox="-.5 0 %d %d"><path d="%s"/></svg>',
.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. --
-. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..
}],
-'Tap code' => [disptap(qw{
+'Tap code' => [map { disptap($_) } qw{
11 12 13 14 15 21 22 23 > 24 25 31 32
33 34 35 41 42 43 44 45 51 52 53 54 55
-})],
-'Short Tap' => [disptap(qw{
+}],
+'Short Tap' => [map { disptap($_) } qw{
11 12 13 14 21 22 23 20 > 31 -13 32 33
30 41 42 -13 43 40 10 51 52 53 50 -31 -40
-})],
+}],
'Cards' => [(
map { chr(0x1F0A0 + $_), sprintf('<b>%s</b>', chr(0x1F0B0 + $_)) } # spades, hearts
1 .. 11, 13, 14 # A 2-10 J Q K