Define a matrix : matrix

### 5.43.25 Define a matrix : matrix

matrix takes three arguments :

- two integers n and p.
- 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 build.

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

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

or first define the h function:

h(j,k):=j+k

then, input:

matrix(4,3,h)

Output :

[[2,3,4],[3,4,5],[4,5,6],[5,6,7]]

Note the argument order and the fact that the indices are counted starting from 1. If the last argument is not provided, it defaults to 0.