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] }
In reply to Re (tilly) 1: uneven abs!
by tilly
in thread Closest-value-in-list Golf!
by larryk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |