Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: reduce like iterators

by LanX (Saint)
on Jan 03, 2011 at 22:08 UTC ( [id://880266]=note: print w/replies, xml ) Need Help??


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

As already stated in the OP the need to appropiately name a whole new family of reduce-like iterators is an extra problem.

At least for me it's more complicated than implementing them.

But if it's easier for you to baptize reduce-like maps, greps, parts, and so on in a quick post, I would appreciate to hear your suggestions

If I was forced to chose only one implementation I would certainly chose a reduce like map, like you did, because it has the biggest flexibility.

But I'd prefer to have a solution where map is still named map and grep ist still grep!

IMHO extra options and special vars should activate and supply the needed functionality.

Cheers Rolf

Replies are listed 'Best First'.
Re^5: reduce like iterators
by ikegami (Patriarch) on Jan 03, 2011 at 23:17 UTC

    As already stated in the OP the need to appropiately name a whole new family of reduce-like iterators is an extra problem.

    Your always free to not give it a name, leaving it as

    my @b; for (@a) { push @b, $_ if !@b || $_ ne $b[-1]; }
    or
    my @b = list_reduce { 0, $a || $b ne $_->[-1] ? $b : () } 1, @a;

    But they're not very readable.

    But I'd prefer to have a solution where map is still named map and grep ist still grep

    You complain that there's "a lack of iterators allowing to compare successive elements", yet you wouldn't want to use them if they existed?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found