Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: map-like hash iterator

by particle (Vicar)
on Nov 06, 2002 at 23:32 UTC ( #210960=note: print w/ replies, xml ) Need Help??

in reply to map-like hash iterator

see mugwumpjism's prior art in his response to the mapcar -- map for more than one list node.

code here for those too lazy to click above...

sub mapeach (&\%) { my $sub = shift; my $hash = shift or do { require Carp; Carp::croak( "mapeach: Nothing to map" ); }; my @ret; while ( my ($k, $v) = each %{$hash}) { local ($_) = $k; push @ret, $sub->($k, $v); } return wantarray ? @ret : { @ret }; }

~Particle *accelerates*

Comment on Re: map-like hash iterator
Select or Download Code
Replies are listed 'Best First'.
Re: Re: map-like hash iterator
by jdporter (Canon) on Nov 07, 2002 at 00:00 UTC

    Prior art? He posted that on 2001-11-30. My post to FWP was on 2001-03-29.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2015-10-07 03:03 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls