Last active
December 18, 2021 19:26
-
-
Save JJ/1d08d02a1b57b38d1325fc6162b6fe9f to your computer and use it in GitHub Desktop.
Embedding Text::Chart code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit module Text::Chart; | |
constant $default-char is export = "█"; | |
sub vertical ( Int :$max = 10, | |
Str :$chart-chars = $default-char, | |
*@data ) is export { | |
my $space = " "; | |
my @chars = $chart-chars.comb; | |
my $chart; | |
for $max^...0 -> $i { | |
for 0..^@data.elems -> $j { | |
$chart ~= @data[$j] > $i ?? @chars[$j % @chars.elems] !! | |
$space; | |
} | |
$chart ~= "\n"; | |
} | |
return $chart; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment