Question: How do I append an element to an Array?

I have a small Maple program which is manipulating lists which have a habit of becoming too long for maple to handle, which yields the error " Error, assigning to a long list, please use Arrays".

In the procedure in question, I make repeated statements of the form

 

foo := [op(2..nops(foo),foo), bar];


which is fine until the lists get longer than about 200 elements, or so.

The Maple help (and the error) suggest instead to use the data type Array, but I don't see an easy way to perform the same task using that data type: The closest that I can see (which feels very inefficient) is something along the lines of

 

foo := Array([op(2..ArrayNumElems(foo), convert(foo,'list', nested)),bar]);

 

which seems absurd; first we convert the array back into a list, then apply op() to it to select a particular range, append the extra term, and then convert it back into an Array.

 

So is there a better way to do this? If the problem with using lists is a memory one, is it really the case that this here is faster?

Please Wait...