GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing reference.wolfram.com — Array: Create a list from a function—Wolfram Documentation Array[f,n] generates a list of length n, with elements f[i]. Array[f,n,r] generates a list using the index origin r. Array[f,n,{a,b}] generates a list using n values from a to b. Array[f,{n1,n2,…}] generates an n1×n2×… array of nested lists, with elements f[i1,i2,…]. Array[f,{n1,n2,…},{r1,r2,…}] generates a list using the index origins ri (default 1). Array[f,{n1,n2,…},{{a1,b1},{a2,b2},…}] generates a list using ni values from ai to bi. Details
Examples
Basic Examples
Scope
Array Element Specification
Index Specification
Head Specification
Applications
Properties & Relations
Neat Examples
See Also
Tech Notes
Related Guides
Related Workflows
Related Links
History
Cite this Page
ArrayArray[f,n] generates a list of length n, with elements f[i]. Array[f,n,r] generates a list using the index origin r. Array[f,n,{a,b}] generates a list using n values from a to b. Array[f,{n1,n2,…}] generates an n1×n2×… array of nested lists, with elements f[i1,i2,…]. Array[f,{n1,n2,…},{r1,r2,…}] generates a list using the index origins ri (default 1). Array[f,{n1,n2,…},{{a1,b1},{a2,b2},…}] generates a list using ni values from ai to bi. Details
Examplesopen all close allBasic Examples (5)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}}]Scope (11)Array Element Specification (5)Create a 3×2 array using an indexed symbol: Array[a, {3, 2}]Create a 4×4 array using a subscript: Array[Subscript[a, ##]&, {4, 4}]Create a Hilbert matrix: Array[(1/# + #2 - 1)&, {3, 3}]Use named function slots: Array[Function[{i, j}, (1/i + j - 1)], {3, 3}]Compare with the built-in function: % == %% == HilbertMatrix[3]Create a constant array: Array[x&, {5, 5}]Use ## to pick up a sequence of indices: Array[FromDigits[{##}]&, {2, 3, 4}]Index Specification (4)Create a 1D array: Array[f, 10]Create a 1D array, starting the indices at 0: Array[f, 10, 0]Create a 3×2 array: Array[f, {3, 2}]Create a 4×3×2 array with index-dependent origins: Array[f, {4, 3, 2}, {0, -1, -2}]Head Specification (2)Use a non-default head for each level of the array: Array[f, {3, 3}, 1, g]Use Plus instead of List to combine elements: Array[a, {2, 3}, 1, Plus]Any symbol with attribute Flat would produce the same shape: SetAttributes[f, Flat];
Array[a, {2, 3}, 1, f]Applications (4)Totally antisymmetric tensor: Array[Signature[{##}]&, {3, 3, 3}]Compare with the built-in LeviCivitaTensor: % == LeviCivitaTensor[3]Lower-triangular matrix: Boole[Array[Greater, {5, 5}]]//MatrixFormMatrix 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]//MatrixFormDet[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π}]Properties & Relations (4)ConstantArray[c,dims] and Array[c&,dims] are equivalent: dims = RandomInteger[{1, 4}, {5}];ConstantArray[c, dims] === Array[c&, dims]When c is a machine number, ConstantArray is much faster for large arrays: {First[Timing[ca = ConstantArray[0., {2000, 2000}]]],
First[Timing[a = Array[0.&, {2000, 2000}]]],
ca === a}Array[f,dims] can be generated using Table: dims = RandomInteger[{1, 5}, {RandomInteger[{2, 5}]}];
f[args___] := Total[{args}]a = Array[f, dims];Set up the Table limit specifications: v = Array[x, Length[dims]];
tl = Transpose[{v, dims}]Use Apply to splice them into a Table command: t = Table[f@@v, ##]&@@ tl;The result is identical to the array generated using Array: a === tSparseArray[{i_,j_}->f[i,j],dims] gives a sparse representation of Array[f,dims]: dims = RandomInteger[{1, 10}, {2}];
f[i_, j_] := i - 2 js = SparseArray[{i_, j_} -> f[i, j], dims]a = Array[f, dims]The results are Equal: s == aThe objects are not identical, but the represented arrays are: {SameQ[s, a], SameQ[Normal[s], a]}Compute Array in parallel: Parallelize[Array[Prime, 20]]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}]See AlsoTable ConstantArray SparseArray Grid ArrayPlot Tuples ArrayFlatten Tech NotesRelated GuidesRelated Workflows
Related Workflows
▪
HistoryIntroduced in 1988 (1.0) | Updated in 1999 (4.0) ▪ 2000 (4.1) ▪ 2002 (4.2) ▪ 2012 (9.0)
Wolfram Research (1988), Array, Wolfram Language function, https://reference.wolfram.com/language/ref/Array.html (updated 2012).
TextWolfram Research (1988), Array, Wolfram Language function, https://reference.wolfram.com/language/ref/Array.html (updated 2012). CMSWolfram Language. 1988. "Array." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Array.html. APAWolfram Language. (1988). Array. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Array.html BibTeX@misc{reference.wolfram_2026_array, author="Wolfram Research", title="{Array}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Array.html}", note=[Accessed: 12-November-2026]} BibLaTeX@online{reference.wolfram_2026_array, organization={Wolfram Research}, title={Array}, year={2012}, url={https://reference.wolfram.com/language/ref/Array.html}, note=[Accessed: 12-November-2026]} |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |