NAME
List::Zip - Module to zip lists.
DESCRIPTION
Provides functionality to zip lists. The provided subroutine returns a list formed from the input lists.
List::MoreUtils also provides functionality to mesh
lists. However, this implementation differs. If the lists passed to zip
have different sizes all the the lists will be truncated to the same size as the smallest list.
SYNOPSIS
use List::Zip;
my @zipped = List::Zip->zip(
[ 1, 2, 3, 4, 5 ], [ 'one', 'two', 'three', 'four', 'five' ]
);
say $zipped[0]->[0]; # 1
say $zipped[0]->[1]; # one
say $zipped[1]->[0]; # 2
say $zipped[1]->[1]; # two
# We can get back to the original structure before zipping by zipping
# the list again with no additional lists
my @unzipped = List::Zip->zip(@zipped);
say for @{ $unzipped[0] }; # 1 2 3 4 5
say for @{ $unzipped[1] }; # one two three four five
METHODS
zip
Converts this list by combining corresponding elements from the input lists into lists.
my $zipped = List::Zip->zip([ 1 .. 5 ], [ 6 .. 10 ]);
The structure of the list returned by zipping the above is:
[ 1, 6 ], [ 2, 7 ], [ 3, 8 ], [ 4, 9 ], [ 5, 10 ]
EXPORTS
None. Methods provided by this module are class methods so should be invoked by the class.
List::Zip->zip(@lists);
SEE ALSO
AUTHOR
Lloyd Griffiths
COPYRIGHT
This software is copyright (c) 2014 by Lloyd Griffiths.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.