[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] Closest hash value
>>>>> "FD" == Fergal Daly <fergal@esatclear.ie> writes:
FD> At 15:29 16/07/99 -0400, Chaim Frenkel wrote:
>> Since you want to avoid the memory for copies how about just walking
>> the keys?
>> do { $best = $_; last} for keys %h;
>> do { $best = $_ if abs($_ - $key) < abs($best - $key) } for (keys %h);
FD> You can get the "first" key with
FD> ($best) = each %h;
I know, but I'm not sure if that is optimized. It may cause all
1_000_000 keys to be copied to the stack and then the first item
removed.
Anyone know for sure?
<chaim>
--
Chaim Frenkel Nonlinear Knowledge, Inc.
chaimf@pobox.com +1-718-236-0183
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe