NAME
List::Comprehensions - allows for list comprehensions in Perl.
SYNOPSIS
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];
}
}
}
FUNCTIONS
- PF($$;@)
-
For parallel comprehensions. ( flat zips according to minimal length ) eg: PF( [0..5], ['a'..'z'] ) is: [ 0, 'a', 1,'b' ... 5,'f' ]
- P($$;@)
-
For parallel comprehensions. ( zips according to minimal length ) eg: P( [0..5], ['a'..'z'] ) is: [ [0,'a'], [1,'b'] ... [5,'f'] ]
- comp1(&@)
-
Anonymous comprehensions (slighly faster) comp1 sub { }, arg, [arg] arg: array ref | guard subs
- comp2(&@)
-
Named comprehensions comp2 sub { }, arg, [arg] arg: [name => ] array ref | guard subs
AUTHOR
Jeremy Cortner <jcortner@cvol.net>
COPYRIGHT
Copyright (C) 2003, Jeremy Cortner
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.