in reply to Closest-value-in-list Golf!
First of all I don't think that strict is a very useful restriction in golf. For instance a useful trick is to use punctuation variables like $, because Perl parses $,for differently than $_for. But using $, is strict-compliant in letter even though it definitely is not in spirit!
That said the natural approach at 46 letters happens to be strict-compliant:
sub g{ (sort{abs($a-$_[1])<=>abs$b-$_[1]}@{$_[0]})[0] }
|
---|
Replies are listed 'Best First'. | |
---|---|
uneven abs!
by larryk (Friar) on May 29, 2001 at 18:52 UTC | |
by tilly (Archbishop) on May 29, 2001 at 20:36 UTC | |
by larryk (Friar) on May 29, 2001 at 22:57 UTC | |
Re: Re (tilly) 1: Closest-value-in-list Golf!
by suaveant (Parson) on May 29, 2001 at 19:17 UTC |
In Section
Meditations