Skip to content

ConstantArray

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

ConstantArray[c, n]

generates a list of n copies of the element c.

ConstantArray[c, {n1, n2, ...}]

generates an n1 x n2 x ... nested array of copies of c.

Examples (2)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (2)

In[1]:= ConstantArray[c, 5]
Out[1]= {c, c, c, c, c}

In[2]:= ConstantArray[0, {2, 3}]
Out[2]= {{0, 0, 0}, {0, 0, 0}}

Implementation notes

Attributes: Protected.

References

See also: List, NDArrayQ