### Re: binary search with reference to append

- Posted by petelomax Jun 13, 2014
- 1891 views

I'd never seen this before. Can someone please enlighten me. In std/search.e I find:

public function binary_search(object needle, sequence haystack, integer start_point = 1, integer end_point = 0)

In std/primes.e I find:

public function next_prime(integer n, object fail_signal_p = -1, atom time_out_p = 1) ... -- Assumes that most searches will be less than about 1000 if n<1009 and 1009<=list_of_primes[$] then i = binary_search(n, list_of_primes, 1 ,169) else i = binary_search(n, list_of_primes) end if

Is that like a *major* win in some benchmark or something? Even if list_of_primes almost fills available memory, we're talking like 32 or 64 chops max, so my gut feeling is those "1009" tests are an overhead many more times than a saving, though I could well be wrong. Otherwise I cannot see why there is an end_point, and given that the above is all I could find, I see absolutely no reason whatsoever to have a start point.

Pete