This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Functional Operations /

2.2.6 Building Lists from Functions

Making lists from functions.

This makes a list of 5 elements, each of the form p[i].

In[1]:= Array[p, 5]


Here is another way to produce the same list.

In[2]:= Table[p[i], {i, 5}]


This produces a list whose elements are .

In[3]:= Array[ # + #^2 &, 5]


This generates a matrix whose entries are m[i, j].

In[4]:= Array[m, {2, 3}]


This generates a matrix whose elements are the squares of the sums of their indices.

In[5]:= Array[Plus[##]^2 &, {3, 3}]


NestList and FoldList were discussed in Section 2.2.2. Particularly by using them with pure functions, you can construct some very elegant and efficient Mathematica programs.

This gives a list of results obtained by successively differentiating with respect to .

In[6]:= NestList[ D[#, x]&, x^n, 3 ]