WLJS LogoWLJS Notebook

ConstantArray

ConstantArray[c, n] generates a list of n copies of the element c.

ConstantArray[c, {n1, n2, ...}] generates a nested array of copies of c.

Examples

Create a list of repeated elements:

ConstantArray[x, 5]
(* {x, x, x, x, x} *)

Create a matrix of zeros:

ConstantArray[0, {2, 3}]
(* {{0, 0, 0}, {0, 0, 0}} *)

Please visit the official Wolfram Language Reference for more details.

On this page