RosettaCodeData/Task/Sparkline-in-unicode/Perl-6/sparkline-in-unicode.pl6
2019-09-12 10:33:56 -07:00

7 lines
348 B
Raku

constant @bars = '' ... '';
while prompt 'Numbers separated by anything: ' -> $_ {
my @numbers = map +*, .comb(/ '-'? [[\d+ ['.' \d*]?] | ['.' \d+]] /);
my ($mn,$mx) = @numbers.minmax.bounds;
say "min: $mn.fmt('%5f'); max: $mx.fmt('%5f')";
say @bars[ @numbers.map: { @bars * ($_ - $mn) / ($mx - $mn) min @bars - 1 } ].join;
}