In julia, how to realize a=b[-1:2] as in R without modifying b


Basically, I want to make a copy of some array b after removing some elements. but not change the original b.
I tried splice!(b,1:2) and deleteat!(b,1:2) both would change b.
Thanks for any comments!


See Julia equivalent to 'not in' in R


Julia has no built-in syntax that is equivalent to R’s vector[-indexes]. Try something like

a = b[setdiff(1:end,indexes_to_remove)]

Of course for these particular elements,


will also work.


That helps! Thanks both of you for the reply!