Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re (tilly) 1: uneven abs!

by tilly (Archbishop)
on May 29, 2001 at 20:36 UTC ( #83995=note: print w/replies, xml ) Need Help??


in reply to uneven abs!
in thread Closest-value-in-list Golf!

For future reference, I found your spec unclear. In the end I settled on "2 parameters" as being the clearest statement. But it would help in the future if you gave sample test code using the function. Then there can be no doubt.

However if I am allowed to rearrange the arguments, I find it more natural that any special arguments should come first in the list. Giving a 38 character solution:

sub g { (sort{abs$a-$_[0]<=>abs$b-$_[0]}@_)[1] }

Replies are listed 'Best First'.
Re: Re (tilly) 1: uneven abs!
by larryk (Friar) on May 29, 2001 at 22:57 UTC
    Apologies for my ambiguous description. Please take a look at the update I have made and tell me if I make any more sense.

    ps. 38 chars - good job!

    "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://83995]
help
Chatterbox?
[Cosmic37]: sort of anyway... hurls some peaches... :-D
[Cosmic37]: when slurping one can undef the record separator thingy; but presumably one should redefine it afterwards? how?
[Cosmic37]: I'm wondering whether there is a specific/(or at least "usual") command or does one take a copy before undefining and then copy it back after slurping file into a string?
[BarApp]: I need help accessing perl files. I need permission!!!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-06-29 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (672 votes). Check out past polls.