-
-
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
add keepat! (the opposite of deleteat!) #36229
Conversation
Maybe better expressed with https://github.com/mbauman/InvertedIndices.jl and |
Maybe! Someone pointed out this package to me and I forgot to mention it here. But it's quite less discoverable than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable to me. I think the implementation can be generalized, but otherwise, lgtm conceptually. I'd merge if you finish it :)
It feels like I'm missing something, but I asked on slack and this functionality doesn't seem to exist yet in
Base
.keepat!(vector, indices)
deletes items at all indices ofvector
except those which are specified inindices
.In other words, after
keepat!(a, inds)
,a
is equal to the array which would have been obtained bya[inds]
.I'm not sure about the name, it could be maybe
getindex!
, or the feature could be incorporated indeleteat!
with a keyword.