Eric Strom > List-Gen > List::Generator

Download:
List-Gen-0.974.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  2
View/Report Bugs
Source  

NAME ^

List::Generator - provides functions for generating lists

VERSION ^

version 0.974

SYNOPSIS ^

this module is an alias for List::Gen. it is the same as List::Gen in every way.

    use List::Generator;

    my $range = <1 .. 1_000_000_000 by 3>;

    my $squares = gen {$_ ** 2} <1..>;

    my $fib = <0, 1, *+* ...>;

    say "@$fib[0 .. 10]"; # 0 1 1 2 3 5 8 13 21 34 55

    list(1 .. 5)->map('*2')->say; # 2 4 6 8 10

    <1..>->zip('.' => <a..>)->say(5); # 1a 2b 3c 4d 5e

each line below prints '1 9 25 49 81' :

    functions:           (gen {$_**2} filter {$_ % 2} 1, 10)->say;

    list comprehensions: <**2 for 1 .. 10 if odd>->say;

    dwimmy methods:      <1..10>->grep('odd')->map('**2')->say;

    normal methods:      range(1, 10)->grep(sub {$_%2})->map(sub {$_**2})->say;

LINKS ^

AUTHOR ^

Eric Strom, <asg at cpan.org>

COPYRIGHT & LICENSE ^

copyright 2009-2011 Eric Strom.

this program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

see http://dev.perl.org/licenses/ for more information.

syntax highlighting: