Perl Monk, Perl Meditation | |
PerlMonks |
Re: getting elements from an array based on a value not in the arrayby Ieronim (Friar) |
on Aug 11, 2006 at 19:42 UTC ( [id://566926]=note: print w/replies, xml ) | Need Help?? |
if lima1 is right, you need to specify what you want to get if $target is in the @test and if $size exceeds the boundaries of the array. Next problem is processing duplicates.
I.e., what do you want to get if $target = 5 or if $target = 0? After you define this, all you need is to implement binary search like BrowserUK's. NOTE: his solution does not handle the case when $target is outside the array at all. s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print
In Section
Seekers of Perl Wisdom
|
|