Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose matrices are represented as lists of lists, as in the 3-by-4 case: [ [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33,

Suppose matrices are represented as lists of lists, as in the 3-by-4 case: [ [11, 12, 13, 14],
[21, 22, 23, 24],
[31, 32, 33, 34] ]
The car operator can be used to get the first row of such a matrix: (car [ [11, 12, 13, 14],
[21, 22, 23, 24],
[31, 32, 33, 34] ] )
will return the list [11, 12, 13, 14].
Similarly, cdr can be used to get the remaining rows after the first.
But, what if we want to extract the first column, made up of the first element of each row. A combination of map and car can be used for this purpose:
( map ( car [ [11, 12, 13, 14], [21, 22, 23, 24],
[31, 32, 33, 34] ] ) )
will return the list [11, 21, 31]. Here car is applied to each of the three lists corresponding to the three rows of the matrix. From each row, car extracts the first element, so the overall effect is to extract the first column.
Similarly, the remaining columns after the first can be extracted using a combination of map and cdr:
( map ( cdr [ [11, 12, 13, 14], [21, 22, 23, 24],
[31, 32, 33, 34] ] ) )
will return the list [ [12, 13, 14], [22, 23, 24], [32, 33, 34] ] .
Use this representation where matrices are represented as lists of lists, to implement the following operations on matrices. Write, execute, and thoroughly test your Dr. Racket recursive functions.
(a) Add corresponding elements of two matrices.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions