### 5.43.24 Build a matrix with a function : makemat

makemat takes three arguments :

- a function of two variables j and k which should return the value of aj,k, the element of row index j and column index k of the matrix to be built.
- two integers n and p.

makemat returns the matrix A=(aj,k) (j=0..n−1 and k=0..p−1) of dimension n × p.
Input :

makemat((j,k)->j+k,4,3)

or first define the h function:

h(j,k):=j+k

then, input:

makemat(h,4,3)

Output :

[[0,1,2],[1,2,3],[2,3,4],[3,4,5]]

Note that the indices are counted starting from 0.