作业scheme – CSCI 3136: Assignment 8

CSCI 3136: Assignment 8

Tami Meredith, Summer 2022

Write scheme programs to accomplish each of the following tasks. You may not use loops or any built-in procedure name that ends with !. Do not use the display procedure. Submit your results, on Brightspace, as a single file named a 8 .scm. Your submissions should obey good programming style (e.g., comments, indentation, use of whitespace).

1. [ 20 marks] Given a list of integers, write Scheme functions that:
``````a. Find the median of the list.
``````
``````(median (2 9 5 7 4 3))  4.
``````
``````b. Find the mode of the list.
``````
``````(mode (3 6 7 4 9 4 3 8 2 3))  3
``````
``````Code to sort a list of integers is provided on Brightspace.
``````
1. [ 3 0 marks] A 2-dimensional matrix can be represented using a list of lists. For example, the list ((1 4 3) (4 5 7) (7 8 9)) represents the matrix:
``````1 4 3
4 5 7
7 8 9
``````
``````Write Scheme functions named transpose, sum, and multiply that:
``````
``````a. Transpose a matrix.
b. Add two matrices.
c. Multiply two matrices.
``````
``````You can find explanations of how to perform these operations online if you
dont remember your linear algebra. For simplicity, you can assume that we
are only going to manipulate square matrices.
``````