Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
Array

  • Array[ f , n ] generates a list of length n, with elements f [ i ].
  • Array[ f , , , ... ] generates an array of nested lists, with elements f [ , , ... ].
  • Array[ f , dims , origin ] generates a list using the specified index origin (default 1).
  • Array[ f , dims , origin , h ] uses head h, rather than List, for each level of the array.
  • Example: Array[f, 3].
  • Array[f, 2, 3 ] generates a matrix.
  • Array[#1^#2 &, 2, 2 ].
  • Array[f, 3, 0] generates an array with index origin 0.
  • Array[f, 3, 1, Plus].
  • Note that the dimensions given to Array are not in standard Mathematica iterator notation.
  • See the Mathematica book: Section 1.8.3Section 2.2.6.
  • See also: Table.

    Further Examples

    This creates an array of 3 elements.

    In[1]:=

    Out[1]=

    This creates an array of 2 elements with 3 elements each.

    In[2]:=

    Out[2]=

    This array starts its index at 0.

    In[3]:=

    Out[3]=

    By specifying the function Plus here, the head of the array is changed to Plus from its default value List.

    In[4]:=

    Out[4]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.