in reply to Closest-value-in-list Golf!
I can offer a 47 36 char solution with the use of PDL:
and it is strict-compliant and very straightforward.sub i{my$a=pdl$_[0];minimum_ind(abs($a-$_[1]))}
Of course it returns the index, but that is allowed, isn't it? Otherwise, add 4 chars to get the value.
Hey wait, do you only count the chars between {}? Than we can take of 7, that counts 40 chars. And there is room in the last part:
And we are at 36 chars.sub i{my$a=pdl$_[0];minimum_ind abs$a-pop}
Jeroen
"We are not alone"(FZ)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Closest-value-in-list Golf!
by Anonymous Monk on May 30, 2001 at 00:08 UTC | |
by jeroenes (Priest) on May 30, 2001 at 00:42 UTC |
In Section
Meditations