GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • WOLFRAM
  • Products
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App
  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs
  • Wolfram AI Ecosystem

This view

  • Original page
  • New address

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.

Array[f,dims,origin,h]

uses head h, rather than List, for each level of the array.

Details
Details and Options Details and Options
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

Array

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.

Array[f,dims,origin,h]

uses head h, rather than List, for each level of the array.

Details

  • Parallelize[Array[f,n]] computes Array[f,n] in parallel on all subkernels. »

Examples

open all close all

Basic Examples  (5)

Wolfram Language code: Array[f, 10]
Wolfram Language code: Array[1 + # ^ 2&, 10]

Generate a 3×2 array:

Wolfram Language code: Array[f, {3, 2}]

Generate a 3×4 array:

Wolfram Language code: Array[10#1 + #2&, {3, 4}]

Use index origin 0 instead of 1:

Wolfram Language code: Array[f, 10, 0]

Start with indices 0 and 4 instead of 1:

Wolfram Language code: Array[f, {2, 3}, {0, 4}]

Sample between 0 and 1:

Wolfram Language code: Array[f, 10, {0, 1}]

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

Wolfram Language code: 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:

Wolfram Language code: Array[a, {3, 2}]

Create a 4×4 array using a subscript:

Wolfram Language code: Array[Subscript[a, ##]&, {4, 4}]

Create a Hilbert matrix:

Wolfram Language code: Array[(1/# + #2 - 1)&, {3, 3}]

Use named function slots:

Wolfram Language code: Array[Function[{i, j}, (1/i + j - 1)], {3, 3}]

Compare with the built-in function:

Wolfram Language code: % == %% == HilbertMatrix[3]

Create a constant array:

Wolfram Language code: Array[x&, {5, 5}]

Use ## to pick up a sequence of indices:

Wolfram Language code: Array[FromDigits[{##}]&, {2, 3, 4}]

Index Specification  (4)

Create a 1D array:

Wolfram Language code: Array[f, 10]

Create a 1D array, starting the indices at 0:

Wolfram Language code: Array[f, 10, 0]

Create a 3×2 array:

Wolfram Language code: Array[f, {3, 2}]

Create a 4×3×2 array with index-dependent origins:

Wolfram Language code: Array[f, {4, 3, 2}, {0, -1, -2}]

Head Specification  (2)

Use a non-default head for each level of the array:

Wolfram Language code: Array[f, {3, 3}, 1, g]

Use Plus instead of List to combine elements:

Wolfram Language code: Array[a, {2, 3}, 1, Plus]

Any symbol with attribute Flat would produce the same shape:

Wolfram Language code: SetAttributes[f, Flat]; Array[a, {2, 3}, 1, f]

Applications  (4)

Totally antisymmetric tensor:

Wolfram Language code: Array[Signature[{##}]&, {3, 3, 3}]

Compare with the built-in LeviCivitaTensor:

Wolfram Language code: % == LeviCivitaTensor[3]

Lower-triangular matrix:

Wolfram Language code: Boole[Array[Greater, {5, 5}]]//MatrixForm

Matrix with generic symbolic entries:

Wolfram Language code: m = Array[Subscript[a, ##]&, {3, 4}]
Wolfram Language code: MatrixForm[m]

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

Wolfram Language code: RowReduce[m]//MatrixForm
Wolfram Language code: Det[Take[m, All, 3]]

Sample a function uniformly on an interval:

Wolfram Language code: 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:

Wolfram Language code: dims = RandomInteger[{1, 4}, {5}];
Wolfram Language code: ConstantArray[c, dims] === Array[c&, dims]

When c is a machine number, ConstantArray is much faster for large arrays:

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

Array[f,dims] can be generated using Table:

Wolfram Language code: dims = RandomInteger[{1, 5}, {RandomInteger[{2, 5}]}]; f[args___] := Total[{args}]
Wolfram Language code: a = Array[f, dims];

Set up the Table limit specifications:

Wolfram Language code: v = Array[x, Length[dims]]; tl = Transpose[{v, dims}]

Use Apply to splice them into a Table command:

Wolfram Language code: t = Table[f@@v, ##]&@@ tl;

The result is identical to the array generated using Array:

Wolfram Language code: a === t

SparseArray[{i_,j_}->f[i,j],dims] gives a sparse representation of Array[f,dims]:

Wolfram Language code: dims = RandomInteger[{1, 10}, {2}]; f[i_, j_] := i - 2 j
Wolfram Language code: s = SparseArray[{i_, j_} -> f[i, j], dims]
Wolfram Language code: a = Array[f, dims]

The results are Equal:

Wolfram Language code: s == a

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

Wolfram Language code: {SameQ[s, a], SameQ[Normal[s], a]}

Compute Array in parallel:

Wolfram Language code: Parallelize[Array[Prime, 20]]

Neat Examples  (3)

Array of powers:

Wolfram Language code: Array[Power, {5, 5}]

Array of GCDs:

Wolfram Language code: ArrayPlot[Array[GCD, {20, 20}]]

Array of arrays:

Wolfram Language code: Array[Array[x&, #]&, {6}]

See Also

Table  ConstantArray  SparseArray  Grid  ArrayPlot  Tuples  ArrayFlatten

Tech Notes

    ▪
  • Vectors and Matrices
  • ▪
  • Tensors

Related Guides

    ▪
  • Constructing Matrices
  • ▪
  • Constructing Lists
  • ▪
  • Tensors
  • ▪
  • Operations on Vectors
  • ▪
  • List Manipulation
  • ▪
  • Handling Arrays of Data
  • ▪
  • Language Overview
  • ▪
  • Creating & Importing Signals

Related Workflows

    Related Workflows
    ▪
  • Create a Matrix
  • ▪
  • Make a Grid of Output Data

Related Links

  • An Elementary Introduction to the Wolfram Language : More about Pure Functions

History

Introduced 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).

Text

Wolfram Research (1988), Array, Wolfram Language function, https://reference.wolfram.com/language/ref/Array.html (updated 2012).

CMS

Wolfram Language. 1988. "Array." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Array.html.

APA

Wolfram 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]}

Top
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.