Lets say we want to collect result obtained inside loop, but do not know in advance how many iteration we need.
In Mathematica, Sow and Reap are used. In Maple, an Array can be used or a queue or a
table.
Mathematica
Remove["Global`*"] result = First@Last@Reap@Do[ Sow[n], {n, 1, 10} ]; result
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Maple
restart; result :=Array([]): for n from 1 to 10 do result(n):=n; od: result(1..10)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]