NAME
List::StackBy - Group runs of similar elements
SYNOPSIS
use List::StackBy;
my @uniq = map { $_->[0] } stack_by { uc } qw/A B b A b B A/;
# A B A b A
my @by_col1 = map { /^\s*(\d+)/ ? $1 : undef } (
"123,foo",
"123,bar",
"456,baz",
);
# ["123,foo", "123,bar"],
# ["456,baz"]
DESCRIPTION
This module provides the function stack_by
.
FUNCTIONS
- stack_by { code } @list
-
Applies the code block to each item in the list and returns a list of arrays containing runs of elements for which the code block returned the same value. Items for which the code block returns an undefined value are isolated from the rest.
EXPORTS
stack_by
by default.
AUTHOR / COPYRIGHT / LICENSE
Copyright (c) 2018 Bjoern Hoehrmann <bjoern@hoehrmann.de>.
This module is licensed under the same terms as Perl itself.