Re: binary search with reference to append
- Posted by jaygade Jun 14, 2014
- 1863 views
I can't argue for or against sending a slice to the function. However, sp and ep ARE optional arguments which will probably not be used most of the time.
In addition, nothing prevents you from sending a slice to the function as written. It should work just fine with a slice.
So call the function with a slice and skip using sp and ep. Problem solved.
I'm not entirely convinced on the added functionality of returning a "possible" index as a negative number though. It almost seems like the job of another function, that should return a euphoria tuple sequence such as {index, FOUND} or {index, NOT_FOUND}.
The more I read about other languages and learn about tuples, the more I can relate them to Euphoria's sequences and find the long-proposed idea of the {A, B} = {val1, val2} syntax.
[EDIT] Nice with the edit history.