Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^6: reduce like iterators

by ikegami (Patriarch)
on Jan 03, 2011 at 19:28 UTC ( [id://880244]=note: print w/replies, xml ) Need Help??


in reply to Re^5: reduce like iterators
in thread reduce like iterators

It's a bit cleaner if ($state, @to_push) is returned.

my @b = list_reduce { undef, !@$_ || $b ne $_->[-1] ? $b : () } undef, + @a; my @b = list_reduce { 0, !@$_ || $b ne $_->[-1] ? $b : () } 1, @a; my @b = list_reduce { $b, defined($b) && $b ne $a ? $b : () } undef, @ +a; my @b = list_reduce { $b, grep defined && $_ ne $a, $b } undef, @a;

(@a may not start with undef for the last two to work properly.)

This actually looks like map now (as it should).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found