Skip to content

Instantly share code, notes, and snippets.

@semifor
Created December 19, 2014 23:31
Show Gist options
  • Select an option

  • Save semifor/b3c31dd02ed5e158b8ab to your computer and use it in GitHub Desktop.

Select an option

Save semifor/b3c31dd02ed5e158b8ab to your computer and use it in GitHub Desktop.
# For some reason, this was raising hell after adding
# use namespace::autoclean;
my $percent_captions = sub {
my @left = @_[ 0 .. $#_ - 1 ];
my @right = @_[ 1 .. $#_ ];
return "< $_[0]%", pairwise {"$a to $b%"} @left, @right;
};
my @pcts = ( 1, 5, 10, 25, 50, 75, 100 );
my @pct_captions = $percent_captions->(@pcts);
# So, I replaced it with this.
my @pcts = ( 1, 5, 10, 25, 50, 75, 100 );
my @pct_captions = (
"< $pcts[0]%",
map "$pcts[$_-1] to $pcts[$_]%", 1..$#pcts
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment