({{, (RefLink[Array, paclet:ref/Array])[f,n]
generates a list of length n, with elements f[i]. }, {, (RefLink[Array, paclet:ref/Array])[f,n,r]
generates a list using the index origin r.}, {, (RefLink[Array, paclet:ref/Array])[f,n,{a,b}]
generates a list using n values from a to b.}, {, (RefLink[Array, paclet:ref/Array])[f,{(Subscript[n, 1]),(Subscript[n, 2]),…}]
generates an (Subscript[n, 1])×(Subscript[n, 2])×… array of nested lists, with elements f[(Subscript[i, 1]),(Subscript[i, 2]),…]. }, {, (RefLink[Array, paclet:ref/Array])[f,{(Subscript[n, 1]),(Subscript[n, 2]),…},{(Subscript[r, 1]),(Subscript[r, 2]),…}]
generates a list using the index origins (Subscript[r, i]) (default 1). }, {, (RefLink[Array, paclet:ref/Array])[f,{(Subscript[n, 1]),(Subscript[n, 2]),…},{{(Subscript[a, 1]),(Subscript[b, 1])},{(Subscript[a, 2]),(Subscript[b, 2])},…}]
generates a list using (Subscript[n, i]) values from (Subscript[a, i]) to (Subscript[b, i]).}, {, (RefLink[Array, paclet:ref/Array])[f,dims,origin,h]
uses head h, rather than (RefLink[List, paclet:ref/List]), for each level of the array. }})

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Array[f,10]

Array[1+#^2&,10]

Generate a 3×2 array:

Array[f,{3,2}]

Generate a 3×4 array:

Array[10#1+#2&,{3,4}]

Use index origin 0 instead of 1:

Array[f,10,0]

Start with indices 0 and 4 instead of 1:

Array[f,{2,3},{0,4}]

Sample between 0 and 1:

Array[f, 10, {0,1}]

Use ranges {-1/2,1/2} and {0,1}:

Array[f, {2,3},{{-1/2,1/2},{0,1}}]

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (2)

Use ## to pick up a sequence of indices:

Array[FromDigits[{##}]&,{2,3,4}]

Use (RefLink[Plus, paclet:ref/Plus]) instead of (RefLink[List, paclet:ref/List]) to combine elements:

Array[a,{2,3},1,Plus]

OpenersExampleSection2(Spacer1)Applications  (5)

3×3 matrix of 0s:

Array[0&,{3,3}]

Totally antisymmetric tensor:

Array[Signature[{##}]&,{3,3,3}]

Lower-triangular matrix:

Boole[Array[Greater,{5,5}]]//MatrixForm

Matrix with generic symbolic entries:

m=Array[(Subscript[a, ##])&,{3,4}]

MatrixForm[m]

Use it to see the effects of some linear algebra functions:

RowReduce[m]//MatrixForm

Det[Take[m,All,3]]

Sample a function uniformly on an interval:

ListPlot[Array[Sin[2 #] - Cos[3 #]&,50,{0, 2π}], Filling->Axis, DataRange->{0,2π}]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

(RefLink[ConstantArray, paclet:ref/ConstantArray])[c,dims] and (RefLink[Array, paclet:ref/Array])[c&,dims] are equivalent:

dims=RandomInteger[{1,4},{5}];

ConstantArray[c,dims]===Array[c&,dims]

When c is a machine number, (RefLink[ConstantArray, paclet:ref/ConstantArray]) is much faster for large arrays:

{First[Timing[ca=ConstantArray[0.,{2000,2000}]]],
First[Timing[a=Array[0.&,{2000,2000}]]],
ca===a}

(RefLink[Array, paclet:ref/Array])[f,dims] can be generated using (RefLink[Table, paclet:ref/Table]):

dims=RandomInteger[{1,5},{RandomInteger[{2,5}]}];
f[args___]:=Total[{args}]

a = Array[f,dims];

Set up the (RefLink[Table, paclet:ref/Table]) limit specifications:

v=Array[x,Length[dims]];
tl=Transpose[{v,dims}]

Use (RefLink[Apply, paclet:ref/Apply]) to splice them into a (RefLink[Table, paclet:ref/Table]) command:

t = Table[f@@v,##]&@@ tl;

The result is identical to the array generated using (RefLink[Array, paclet:ref/Array]):

a===t

(RefLink[SparseArray, paclet:ref/SparseArray])[{i_,j_}->f[i,j],dims] gives a sparse representation of (RefLink[Array, paclet:ref/Array])[f,dims]:

dims=RandomInteger[{1,10},{2}];
f[i_,j_]:= i-2 j

s=SparseArray[{i_,j_}->f[i,j],dims]

a=Array[f,dims]

The results are (RefLink[Equal, paclet:ref/Equal]):

s==a

The objects are not identical, but the represented arrays are:

{SameQ[s,a],SameQ[Normal[s],a]}

OpenersExampleSection4(Spacer1)Neat Examples  (3)

Array of powers:

Array[Power,{5,5}]

Array of GCDs:

ArrayPlot[Array[GCD,{20,20}]]

Array of arrays:

Array[Array[x&,#]&,{6}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Table, paclet:ref/Table])  ▪  (RefLink[ConstantArray, paclet:ref/ConstantArray])  ▪  (RefLink[SparseArray, paclet:ref/SparseArray])  ▪  (RefLink[Grid, paclet:ref/Grid])  ▪  (RefLink[ArrayPlot, paclet:ref/ArrayPlot])  ▪  (RefLink[Tuples, paclet:ref/Tuples])  ▪  (RefLink[ArrayFlatten, paclet:ref/ArrayFlatten])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Vectors and Matrices, paclet:tutorial/VectorsAndMatrices])}, {▪(RefLinkPlain[Tensors, paclet:tutorial/Tensors])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Constructing Lists, paclet:guide/ConstructingLists])}, {▪(RefLinkPlain[Constructing Matrices, paclet:guide/ConstructingMatrices])}, {▪(RefLinkPlain[Operations on Vectors, paclet:guide/OperationsOnVectors])}, {▪(RefLinkPlain[Tensors, paclet:guide/Tensors])}, {▪(RefLinkPlain[List Manipulation, paclet:guide/ListManipulation])}, {▪(RefLinkPlain[Handling Arrays of Data, paclet:guide/HandlingArraysOfData])}, {▪(RefLinkPlain[Language Overview, paclet:guide/LanguageOverview])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/29-more-about-pure-functions.html])(WebLink[: More about Pure Functions, https://www.wolfram.com/language/elementary-introduction/29-more-about-pure-functions.html])}})}})