List::Comprehensions - allows for list comprehensions in Perl.
use List::Comprehensions; use warnings; my @res = (); @res = comp1 { [ @_ ] } [0..4], [0..4], [0..4]; no warnings 'once'; @res = comp2 { [$i, $j, $k] } i => [0..4], j => [0..4], k => [0..4]; # if strict 'vars' is on, use lexicals. eg: use strict 'vars'; my ($i, $j, $k); @res = comp2 { [$i, $j, $k] } i => [0..4], j => [0..4], k => [0..4]; # each being less efficient but equivelant to @res = (); for $i ( 0..4 ) { for $j ( 0..4 ) { for $k ( 0..4 ) { push @res, [$i, $j, $k]; } } }
For parallel comprehensions. ( flat zips according to minimal length ) eg: PF( [0..5], ['a'..'z'] ) is: [ 0, 'a', 1,'b' ... 5,'f' ]
For parallel comprehensions. ( zips according to minimal length ) eg: P( [0..5], ['a'..'z'] ) is: [ [0,'a'], [1,'b'] ... [5,'f'] ]
Anonymous comprehensions (slighly faster) comp1 sub { }, arg, [arg] arg: array ref | guard subs
Named comprehensions comp2 sub { }, arg, [arg] arg: [name => ] array ref | guard subs
Jeremy Cortner <jcortner@cvol.net>
Copyright (C) 2003, Jeremy Cortner
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.
To install List::Comprehensions, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Comprehensions
CPAN shell
perl -MCPAN -e shell install List::Comprehensions
For more information on module installation, please visit the detailed CPAN module installation guide.