That said the natural approach at 46 letters happens to be strict-compliant:
sub g{ (sort{abs($a-$_[1])<=>abs$b-$_[1]}@{$_[0]})[0] }
In reply to Re (tilly) 1: Closest-value-in-list Golf!
by tilly
in thread Closest-value-in-list Golf!
by larryk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |