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
This would be a breaking change, so probably it will be rejected, but anyway:
The function call searchsorted(v, key, by=mytransform) applies mytransform to key, which isn't helpful. It would be more useful if the searchsorted function assumes that the key is already of the type equal to the output of mytransform. The common use for searchsorted is to search the sorted array v for a particular key that is a field or is computed from the fields of the array entries. Typically, the user would know the key but would not want to construct a dummy record whose type is eltype(v) just to hold that key.
Just to be clear, here is a trace of what I mean. I think the first invocation sequence (that gives the error) is more useful than the second.
julia> v = [(2,5), (3,9), (12,15)]
3-element Array{Tuple{Int64,Int64},1}:
(2, 5)
(3, 9)
(12, 15)
julia> searchsortedfirst(v, 7, by = a-> a[2])
ERROR: BoundsError
Stacktrace:
[1] getindex at .\number.jl:78 [inlined]
[2] #5 at .\REPL[4]:1 [inlined]
[3] lt at .\ordering.jl:51 [inlined]
[4] searchsortedfirst at .\sort.jl:178 [inlined]
[5] searchsortedfirst at .\sort.jl:291 [inlined]
[6] #searchsortedfirst#4 at .\sort.jl:293 [inlined]
[7] (::getfield(Base.Sort, Symbol("#kw##searchsortedfirst")))(::NamedTuple{(:by,),Tuple{getfield(Main, Symbol("##5#6"))}}, ::typeof(searchsortedfirst), ::Array{Tuple{Int64,Int64},1}, ::Int64) at .\none:0
[8] top-level scope at REPL[4]:1
julia> searchsortedfirst(v, (99999,7), by = a-> a[2])
2
The text was updated successfully, but these errors were encountered:
This would be a breaking change, so probably it will be rejected, but anyway:
The function call
searchsorted(v, key, by=mytransform)
appliesmytransform
tokey
, which isn't helpful. It would be more useful if thesearchsorted
function assumes that the key is already of the type equal to the output ofmytransform
. The common use forsearchsorted
is to search the sorted arrayv
for a particular key that is a field or is computed from the fields of the array entries. Typically, the user would know the key but would not want to construct a dummy record whose type iseltype(v)
just to hold that key.Just to be clear, here is a trace of what I mean. I think the first invocation sequence (that gives the error) is more useful than the second.
The text was updated successfully, but these errors were encountered: