awohld has asked for the wisdom of the Perl Monks concerning the following question:
Any ideas if "unzip" or "unmesh" exists or an elegant way to implement unzip?my @test1 = qw( 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ); my @test2 = qw( 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 ); # unzip @test1, we know to make it two lists my $unzipped = unzip( 2, @test1 ); $unzipped = [ [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], ] # unzip @test2, we know to make it three lists my $unzipped = unzip( 3, @test2 ); $unzipped = [ [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], [ 1, 2, 3, 4, 5, 6, 7 ], ]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: UnMesh or UnZip List
by AnomalousMonk (Archbishop) on Jun 27, 2016 at 22:49 UTC |