# Adding an entry to a vector, by redefining the vector?

Hello
I have a vector defined with x entrants. When looping over the entries, i want to add one.
Is there a way to do it?

Example - i want my loop over x to be 4 times instead of 3. How is this achievable?

let#index 0
let#x 2,5,8

loop#i x
let#y 100+#index
let#index #index+1

endloop

I know that i can append an entry by:

let#x(3) 1

But that does not make it able to parametric scale, say if i change x to have 6 entries, i will just overwrite index 3 with the value 1.

There is:

``````prog template urs:1

let#A 9,8,9,8,9,1,2,3

\$ results
txb before:
loop#i A
txb A(#i)= #(#A(#i))
endloop

loop#i A
let#Atemp(#i) #A(#i)
endloop

loop#i Atemp
let#A(#i+1) #Atemp(#i)
let#A(#i)   #Atemp(#i)
let#A(#i+1) #Atemp(#i)
endif
endloop

\$ results
txb
txb after:
loop#i A
txb A(#i)= #(#A(#i))
endloop

end
``````

Okay, i see.

I initially tried:

let#x 2,5,8

!to append a value
let#x(3) 10

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

let#A 2,5,8

\$ results
txb before:
loop#i A
txb A(#i)= #(#A(#i))
endloop

loop#i A
let#Atemp(#i) #A(#i)
endloop
let#Acount #i
txb lenght(A) = #Acount

loop#i Atemp
let#A(#i+1) #Atemp(#i)
let#A(#i)   #Atemp(#i)
let#A(#i+1) #Atemp(#i)
endif
endloop

\$ results
txb
txb after:
loop#i A
txb A(#i)= #(#A(#i))
endloop
let#Acount #i
txb lenght(A) = #Acount

end
``````

Okay, thank you very much for you time Mico.