2) build-list is an inbuilt abstract function in scheme
that consumes a natural
number n and a function f consuming natural numbers
(i.e (define (build-list n f) ...) where f consumes natural numbers; see section 21.2)
and outputs the (list (f 0) ... (f (- n 1)))
Use build list to define the function build-matrix that takes
a natural number
n and a function g (that consumes two natural numbers (>=1) and
produces a
number) and prepares the n x n matrix whose i, j th entry is
(g i j).
For example: If g is defined as - (define (g i j) (+ i j)); (build-matrix
3 g)
should output (choose the matrix representation to be a
list of lists of numbers)
(list
(list 2 3 4)
(list 3 4 5)
(list 4 5 6))
i.e the entry in row 1 column 2 is (g 1 2) = 3.
3) Recall the list-pick program from section 17.3. Use list-pick
to develop a
function lookup-matrix that takes a matrix as defined
above and two integers
(>=1) i and j and outputs the i,j^th entry of the matrix
For example:
(matrix-lookup 2 3 (list
(list 2 3 4)
(list 3 4 5)
(list 4 5 6))
should output 5.
4) 21.2.3 (use filter to define some functions)
5) 22.2.3 (rewrite fold using locals and first class functions)