Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: A set of new operators. In keeping with the design of Perl? (aliasing)

by Aristotle (Chancellor)
on May 21, 2003 at 20:58 UTC ( #259887=note: print w/ replies, xml ) Need Help??


in reply to Re: Re^3: A set of new operators. In keeping with the design of Perl? (aliasing)
in thread A set of new operators. In keeping with the design of Perl?

As for the single-pass problem, you can do that too:

use List::Util qw(reduce); @hash{$set}{qw(min max)} = @{ reduce { return [ $a, $b ] if 'ARRAY' ne ref $a; return $a->[0] < $b ? [ $b, $a->[1] ] : $a->[1] > $b ? [ $a->[0], $b ] : $a; } @{$hash{$set}{data}} };
Admittedly more hoop jumping here. Of course that doesn't address the memory problem, but in that case I'd still opt for a counter in a while loop instead. (In keeping with the corresponding use of while and each to traverse a hash.)
for my $min ($hash{$set}{min}) { my $data = $hash{$set}{data}; my $i = -1; while(++$i < @$data) { $min = $min < $data->{$i} ? $min : $data->{$i}; } }

Makeshifts last the longest.


Comment on Re^5: A set of new operators. In keeping with the design of Perl? (aliasing)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-07-31 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls