You could do 'append!(vec, zeros(i-n))'.
On Monday, October 26, 2015 at 3:32:56 PM UTC-4, Cameron McBride wrote: > > Hi All, > > What's the best julian way to do the following: > > function vecadd!(vec, i, v) > n = length(vec) > if n < i > resize!(vec, i) > vec[n+1:i] = 0.0 > end > vec[i] += v > end > > This seems somewhat typical for a growing array that's not just > incremental (i.e. not just a push!() operation), so I feel like I missed > something. Better suggestions? > > Thanks! > > Cameron >