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
See previous discussions at #10593 and the Search & Find Julep. The problems raised here are indeed the parts of the Julep that didn't end up being implemented in Julia 1.0. In particular, #25414 is about searchsorted*, #24865 about findmin/findmax.
findfirst takes a function as the first argument but searchsorted takes the function as by=, like sort. It would be nice to not have different APIs for essentially similar functions. I think that would mean choosing either do or by= for both find* and sort*, but that might not be worth it.
searchsorted's by is not really equivalent to findfirst's first argument (needle).
It would be nice to support predicates in searchsorted, like searchsortedfirst(≥(x), xs) (currently it's searchsortedfirst(xs, x)), searchsortedfirst(>(x), xs), searchsortedfirst(==(x), xs), searchsortedfirst(∈(x:y), xs). These variants are arguably as useful as ≥(x), but currently require careful bookkeeping from the user's part.
As we are talking about major changes anyway, searchsorted would be more composable as findfirst(≥(x), Sorted(xs)) with Sorted being a simple wrapper. This way, libraries would just use findfirst and it will work with arbitrary collections (linear search) and sorted collections (binary search).
There are multiple naming conventions for search functions
findfirst
,findall
return indicesfindmin
/findmax
return(value, key)
pairs (who ever heard of a(value, key)
pair?)searchsorted{,first,last}
return indicesindmin
/indmax
(PR) return indicesI suggest
find
as a "returns indices" convention in 2.0.The text was updated successfully, but these errors were encountered: