andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
282 stars 28 forks source link

Support for `mergewith` and `mergewith!` #73

Closed alecloudenback closed 2 years ago

alecloudenback commented 2 years ago
julia> dict = Dictionary(["a", "b"], [rand(10), rand(10)])
2-element Dictionary{String, Vector{Float64}}
 "a" │ [0.6754523471882936, 0.9575574532471981, 0.6527535430527817, 0.898230973122484, 0.886…
 "b" │ [0.11071336894931672, 0.04832475875008868, 0.954036463626111, 0.6666379467912544, 0.5…

julia> d2 = Dictionary(["a", "b"], [rand(10), rand(10)])
2-element Dictionary{String, Vector{Float64}}
 "a" │ [0.15383191039124666, 0.985055480434822, 0.2125298315455063, 0.08767770837077182, 0.2…
 "b" │ [0.26587711060898767, 0.3254898431836074, 0.9454838456008, 0.1076792806156961, 0.4809…

julia> mergewith!(dict,d2)
ERROR: MethodError: no method matching mergewith!(::Dictionary{String, Vector{Float64}}, ::Dictionary{String, Vector{Float64}})

julia> mergewith(dict,d2)
ERROR: MethodError: no method matching mergewith(::Dictionary{String, Vector{Float64}}, ::Dictionary{String, Vector{Float64}})
alecloudenback commented 2 years ago

my bad, didn't add the first argument, e.g. mergewith!(+,dict,d2)