These are my takes:
Preserving the original array:
julia> function f(x,inds)
y = Vector{eltype(x)}(undef,length(x) - length(inds))
j = 0
for i in Iterators.filter(!in(inds),eachindex(x))
j += 1
@inbounds y[j] = x[i]
end
return y
end
f (generic function with 1 method)
julia> x = collect(1:10); inds = [3,5,6];
julia> @btime f($x,$inds)
72.919 ns (1 allocation: 112 bytes)
7-element Vector{Int64}:
1
2
4
7
8
9
10
Modifying the original array:
julia> function f!(x,inds)
for i in Iterators.reverse(Iterators.filter(in(inds),eachindex(x)))
deleteat!(x,i)
end
return x
end
f! (generic function with 1 method)
julia> @btime f!(x,$inds) setup=(x=copy($x)) evals=1
121.000 ns (0 allocations: 0 bytes)
7-element Vector{Int64}:
1
2
4
7
8
9
10