This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

ConstantArray

ConstantArray
generates a list of n copies of the element c.
ConstantArray
generates an array of nested lists containing copies of the element c.
Make a vector of 10 c's:
Make a 3×4 array of c's:
Make a vector of 10 c's:
In[1]:=
Click for copyable input
Out[1]=
 
Make a 3×4 array of c's:
In[1]:=
Click for copyable input
Out[1]=
A machine-zero vector:
A vector of exact zeros:
A machine-zero matrix:
A matrix of exact zeros:
A vector of ones:
A machine-number vector of ones:
A deeply nested constant array:
Set up an array to use as storage in a program:
Numerically solve using Euler's method:
Find the sum of the elements in a list:
This can also be done with Total:
Use a vector of ones to see the effects of conditioning on the solution of a linear system:
The solution at machine precision has significant errors:
At higher precision, the solution is much better:
Normal[s] is identical to ConstantArray:
ConstantArray is equivalent to Apply[Table[c, ##]&, Map[List, dims]]:
New in 6 | Last modified in 7