-
Notifications
You must be signed in to change notification settings - Fork 28
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
Feature request: support pop!
#81
Comments
Thanks @piever, I think it's a good idea to have something like this (and I've definitely enjoyed using this interface with Part of my reluctance so far is that Another thing is that so far I've reserved method-space (is that a word? is now...) for multidiemsional indices so I'm not sure if the second one is going to work very well with that? |
That's a good point, I see why My main use case for One thought I had is that somehow function antimerge!(d1, d2)
d = empty(d1)
for (key, value) in pairs(d2)
# the two lines below are morally `d[key] = pop!(d1, key, value)`, may not be the most efficient implementation
d[key] = get(d1, key, value)
unset!(d1, key)
end
return d
end (EDIT: I see now that this can be implemented much more efficiently using |
Correct. There is an analogy of Another analogy is with relational (e.g. SQL) inner, left, right, outer, anti, left-anti and right-anti joins (where you are joining on equal keys). So The version I have in my head is something like |
Thanks for a really nice package!
There is a feature of julia Base
Dict
s that I think it's not supported easily here, namely:pop!(d, key)
, similar todelete!(d, key)
but returns the corresponding valued[key]
;pop!(d, key, default)
, similar tounset!(d, key)
but returnsd[key]
(ordefault
if the key was absent).Would it be possible to add overloads for those two methods for
AbstractDictionary
? I'm not sure what is the most efficient way to implement them, but it should be possible to implement them in general with the existing API.The text was updated successfully, but these errors were encountered: