Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Closest-value-in-list Golf!

by suaveant (Parson)
on May 29, 2001 at 17:57 UTC ( #83927=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub g {$n=pop;$h{abs($_-$n)}=$_ for@_;@s=sort{$a<=>$b}keys%h;$h{shift@
    +s};}
    
  2. or download this
    sub g {$n=pop;$h{abs($_-$n)}=$_ for@_;@s=sort{$a<=>$b}keys%h;$h{shift@
    +s}}
    
  3. or download this
    sub g {$n=pop;$h{abs($_-$n)}=$_ for@_;$h{(sort{$a<=>$b}keys%h)[0]}}
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2014-09-21 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls