The problem is to insert a number into a vector given the index.
Mathematica
Matlab
Julia
Fortran
Maple
v:=Vector[row]([1,2,3,4]); v:=Vector[row]([v[1..2],99,v[3..]]); Or Using v:=<1|2|3|4>; v:=<v(1..2)|99|v(3..)>;
|
v :=[ 1 2 99 3 4] |
Python
Python uses zero index. import numpy as np b=np.array([1,2,3,4]) b=numpy.insert(b,2,99) b
|
Out[86]: array([ 1, 2, 99, 3, 4]) |