Instead just build the array instead of mutating, using a comprehension with an ifelse statement.
new_p = [ifelse(i in p_subset_indices,p_subset[i],p) for i in 1:length(p)]
Or use a Zygote.Buffer.
Instead just build the array instead of mutating, using a comprehension with an ifelse statement.
new_p = [ifelse(i in p_subset_indices,p_subset[i],p) for i in 1:length(p)]
Or use a Zygote.Buffer.