Building Lists from Functions

Making lists from functions.

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

Array[p,5]

Here is another way to produce the same list:

Table[p[i],{i,5}]

This produces a list whose elements are i+(i^2):

Array[#+#^2&,5]

This generates a 2×3 matrix whose entries are m[i,j]:

Array[m,{2,3}]

This generates a 3×3 matrix whose elements are the squares of the sums of their indices:

Array[Plus[##]^2&,{3,3}]

(RefLink[NestList, paclet:ref/NestList]) and (RefLink[FoldList, paclet:ref/FoldList]) were discussed in "Applying Functions Repeatedly". Particularly by using them with pure functions, you can construct some very elegant and efficient Wolfram Language programs.

This gives a list of results obtained by successively differentiating (x^n) with respect to x:

NestList[D[#,x]&,x^n,3]