/List-Zip

Perl module for zipping lists

Primary LanguagePerlOtherNOASSERTION

NAME

List::Zip - Module to zip lists.

DESCRIPTION

Provides functionality to zip list structures.

List::MoreUtils also provides functionality to mesh lists. However, this implementation differs. If the lists provided have different sizes all of the the lists will be truncated to the same size as the smallest list.

SYNOPSIS

use List::Zip qw(zip zip_with);

my @zipped      = zip([ 1, 2, 3, 4, 5 ], [ 'one', 'two', 'three', 'four', 'five' ]);
my @unzipped    = zip(@zipped);
my @zipped_with = zip_with([ 1, 2, 3 ], [ 4, 5, 6 ] => sub { return $_[0] + $_[1] });

FUNCTIONS

zip

Converts this list by combining corresponding elements from the input lists into lists.

my @zipped = 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 ])

zip_with

Converts this list by combining corresponding elements from the input lists into lists. The given function is applied to each combination of the corresponding elements.

my @zipped = zip_with([ qw(t f r f) ], [ qw(h a e o) ], [ qw(e t d x) ] => sub {
    return join '', @_;
});

The structure of the list returned by zipping with the above function applied is:

('the', 'fat', 'red', 'fox')

EXPORTS

None by default.

SEE ALSO

List::MoreUtils

List::Gen

AUTHOR

Lloyd Griffiths

COPYRIGHT

This software is copyright (c) 2014-2016 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.