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

Re: Closest-value-in-list Golf!

by ChOas (Curate)
on May 29, 2001 at 18:13 UTC ( #83932=note: print w/replies, xml ) Need Help??


in reply to Closest-value-in-list Golf!

Hey!,

I think it`s shorter, and I got no spaces...

But I don`t know how to count...

sub g{%_=map{abs($_[-1]-$_[$_]),$_}(0..@_-2);$_[$_{(sort{$a<=>$b}keys% +_)[0]}]}

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

Replies are listed 'Best First'.
Re: Re: Closest-value-in-list Golf!
by larryk (Friar) on May 29, 2001 at 18:16 UTC
    count between the {}s of the sub - yours is 71

    "Argument is futile - you will be ignorralated!"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2019-05-26 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (153 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!