That adds value 10 at index 3, but as mentioned - it is not parametric, and wont add at the end of vector x, if i change the length of vector x.
Is there really not an easier other than the one you have shown?
This will work also for enlarging an array (adding last or even 1000th element):
I doubt it can be made more simple since it is not native cadinp function to put new element between old in array (I doubt it is native function of any programing language)
prog template urs:1
head
let#A 2,5,8
$ results
txb before:
loop#i A
txb A(#i)= #(#A(#i))
endloop
let#add_A 10,3 $adds to A value of add_A(0) at pos. add_A(1)
loop#i A
let#Atemp(#i) #A(#i)
endloop
let#Acount #i
txb lenght(A) = #Acount
loop#i Atemp
if #i==#add_A(1)
let#A(#i) #add_A(0)
let#A(#i+1) #Atemp(#i)
elseif #i<#add_A(1)
let#A(#i) #Atemp(#i)
elseif #i>#add_A(1)
let#A(#i+1) #Atemp(#i)
endif
endloop
let#A(#add_A(1)) #add_A(0)
$ results
txb
txb after:
loop#i A
txb A(#i)= #(#A(#i))
endloop
let#Acount #i
txb lenght(A) = #Acount
end