As homework, I must swap letters in a given string. I already figured out how to do this, but not how to display them at once. it involves a for loop. so if I include disp x in the for loop, it displays them between parentheses and a space, but I want them all together, so instead of
"a"
"b"
"c"
I want "abc". Is there a way to do this? Should I push the variable into an array and then display the array after the for loop? How to push variables in to an array?
This is in TI-Nspire CX Cas btw.
To add an element x
to an array A
use augment(A, {x})
.
For your specific case, I would use a string variable (call it string
) to which I concatenate the next letter at each iteration of the for
loop. So if the next letter to be added is in the variable letter
, you would put the following line of code at the end of your for
loop: string := string & letter
.