Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Transform Sequence Problem

by Anonymous Monk
on Jun 19, 2013 at 19:46 UTC ( #1039834=note: print w/ replies, xml ) Need Help??


in reply to Transform Sequence Problem

dominus's Higher-Order Perl, the chapter about iterators?

use Iterator_Utils qw/:all/; my @data = (1, 2, 3); my $data_iter = list_iterator(@data); $f1 = sub { $_ + 1 }; $f2 = sub { log($_) }; $f3 = sub { $_ * 3 }; my $iter = $data_iter; for my $func ($f1, $f2, $f3) { $iter = imap($func, $iter); } while (my $item = NEXTVAL($iter)) { print $item, "\n"; }
(Iterator_Utils.pm available at his web site)
# output 2.07944154167984 3.29583686600433 4.15888308335967


Comment on Re: Transform Sequence Problem
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-10-25 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (146 votes), past polls