-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename search and find functions? #5664
Comments
It seems like the same answer I would give if you asked me instead of Julia
1 is the index of 1 which is the first object in the list that is greater than 0. |
Interesting. I would have assumed |
I did not assume anything, but was very glad to find that the documentation was consistent with the behaviour. I still can't seem to get the connection between the name and the behaviour, so that might be something worth a discussion, as this is an exported function in Base. It is not really a plus for a language to have stdlib functions that is confusing with regard to what they do. |
In fact, searchsorted calls both searchsortedfirst and searchsortedlast (in Stefan had actually suggested not exporting these at one point, but got (But if you can suggest better names...) Kevin On Mon, Feb 3, 2014 at 5:40 PM, Ivar Nesje notifications@github.com wrote:
|
I would describe the function's behavior as "index of the first element in a greater than x". What about |
So, it's actually |
I think the C++ standard library calls these lower_bound and upper_bound (upper_bound returns first greater than, but that is because of indexing style differences in the languages) |
Sad that passing comparison functions to functions is so slow. After thinking about it, it might be more flexible to have a |
Since people keep discussing this, I reopened it. Here's my two cents.
|
They could also be |
That's a good point. Clearly the The situation is worse than I thought and it looks like we need some serious renaming here. The basic functions seem to be We have a slightly odd convention that I found this definition:
which seems to assume that |
Also, I advocate designing around the most natural and general versions of these functions, with performance-related specializations tacked on later as needed. For example, the current It then becomes possible to add |
Closing in favor of #10593. |
To me, this seems like the wrong behavior for
searchsortedfirst
:The text was updated successfully, but these errors were encountered: