Skip to content

Instantly share code, notes, and snippets.

@JJ
Last active Dec 18, 2021
Embed
What would you like to do?
Embedding Text::Chart code
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