%mathpiper,def="MakeVector"

Rulebase("MakeVector",{vec,dimension});
Rule("MakeVector",2,1,True)
[
    Local(res,i);
    res:={};
    i:=1;
    Bind(dimension,AddN(dimension,1));
    While(IsLessThan(i,dimension))
    [
      DestructiveInsert(res,1,ToAtom(ConcatStrings(ToString(vec),ToString(i))));
      Bind(i,AddN(i,1));
    ];
    DestructiveReverse(res);
];

%/mathpiper



%mathpiper_docs,name="MakeVector",categories="User Functions;Lists (Operations)"
*CMD MakeVector --- vector of uniquely numbered variable names
*STD
*CALL
	MakeVector(var,n)

*PARMS

{var} -- free variable

{n} -- length of the vector

*DESC

A list of length "n" is generated. The first entry contains the
identifier "var" with the number 1 appended to it, the second entry
contains "var" with the suffix 2, and so on until the last entry
which contains "var" with the number "n" appended to it.

*E.G.

In> MakeVector(a,3)
Result: {a1,a2,a3};

*SEE RandomIntegerList, ZeroVector
%/mathpiper_docs