ConstantArray
ConstantArray[ s,n ]
ConstantArray[ s,n ] creates a list with n copies of the element s.
| Example | in | out |
|---|---|---|
The list with 5 copies of the number 2. |
ConstantArray[ 2,5 ] |
{2,2,2,2,2} |
The list with 3 copies of the expression sqrt[2]. |
ConstantArray[ sqrt[2],3 ] |
{ sqrt[2], sqrt[2], sqrt[2] } |
The list with n copies of x, where n is defined as 5 and x is undefined in the script. |
ConstantArray[x,n] |
{x,x,x,x,x} |