(75...)sub nn { my@x=@_[0,1];@_=sort{abs$x[0]-$x[1]<abs$a-$b or@x=($a,$b);$a<=>$b}@_;@ +x }
UPDATE
MeowChow pointed out that the parens for the arguments
of abs were not needed. That cut out 3 characters.
Plus by reversing the order of the comparison I managed
to substitute or for and, saving another. That makes it
71...
UPDATE 2
This is sick and slick.
Enjoy verifying that I am perfectly safe in using @_ as my temporary array. I think that 58 is the best I can do...sub nn { ()=sort{abs$_[0]-$_[1]<abs$a-$b or@_=($a,$b);$a<=>$b}@_;@_ }
UPDATE 3</B In reply to Re (tilly) 1: (Golf) Nearest Neighbors
by tilly
petral sent me a /msg explaining how to remove 3 chars
from that solution. I would like to see him post that
since it was his idea, but until he does I want to note
that that solution can be beaten.
in thread (Golf) Nearest Neighbors
by MeowChow
For:
Use:
& & < < > > [ [ ] ]