You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was quite flummoxed last week because I was getting inconsistent answers out of my calls to binary_search in some code.
I eventually realized that my problem was that I was inverting the order of the inputs when generating the output Ordering in the binary_search callback.
But the really frustrating thing was that the current doc for binary_search does not give you the information you need to actually write the callback properly. It seems one's only options are to experimentally determine the input order, or read the source.
So, let's fix the docs here.
Here is some sample code illustrating what I mean in this issue:
This illustrates that "just try it and see" is not actually a good strategy for resolving this ambiguity, because feeding the wrong order can give the right answer, i.e. if you happen to pick the middle element for the first lookup.
The text was updated successfully, but these errors were encountered:
I was quite flummoxed last week because I was getting inconsistent answers out of my calls to
binary_search
in some code.I eventually realized that my problem was that I was inverting the order of the inputs when generating the output
Ordering
in thebinary_search
callback.But the really frustrating thing was that the current doc for
binary_search
does not give you the information you need to actually write the callback properly. It seems one's only options are to experimentally determine the input order, or read the source.So, let's fix the docs here.
Here is some sample code illustrating what I mean in this issue:
which prints:
This illustrates that "just try it and see" is not actually a good strategy for resolving this ambiguity, because feeding the wrong order can give the right answer, i.e. if you happen to pick the middle element for the first lookup.
The text was updated successfully, but these errors were encountered: