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 |
vtjnash
left a comment
There was a problem hiding this comment.
Sounds reasonable to me. I think the implementation can be generalized, but otherwise, lgtm conceptually. I'd merge if you finish it :)
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
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 ofvectorexcept those which are specified inindices.In other words, after
keepat!(a, inds),ais 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.