## CMSC 15100 - Autumn 2005 Lab 3

• Language: Beginning Student
• Teachpack: none
• Lab3 Template (Remember to change the name of this file to your CNET id.)
Extra Credit problems are in red!!

### 0. Designing Functions on Lists

In this lab you will be designing functions which operate on lists.

• You must follow the Design Recipe for each function.
• You must prove to me you function works!!.
• Use helper functions. Your functions need to be readable for humans too!

### 1. Create a template

Create a design template for functions that operate on a generic list of objects `loo`.

### 2. Processing Lists of Numbers

To find the minimum number on a list of numbers you could find the minimum value on a list by first sorting the list in increasing order, then selecting the first element of the list. But on long lists this is extremely inefficient. Use you Design Template from Part 1 to guide your construction. Test these functions thoroughly.

``` ;; minimum: list-of-numbers -> number ;; find minimum value on alon ;; (define (minimum alon) ... ) ```

``` ;; remove-nums: list-of-numbers number -> list-of-numbers ;; remove all numbers less than num from alon ;; (define (remove-nums alon num) ... ) ```

Your grader needs help managing the list of student records. I have defined a structure for a `student`, which consists of a name and a grade. You need to provide a list of al constructors and selectors:

``` ;; a student is a ;; (make-student symbol symbol) (define-struct student (name grade)) ```

``` ;; get-grade: list-of-students symbol -> symbol ;; given alost and name (of student) return grade if student on list ;; Return 'None if student not on list ;; (define (get-grade alost name) ...) ```

``` ;; get-names: list-of-students symbol -> list-of-symbols ;; Return list of all names of students with given grade ;; (define (get-names alost grade)...) ```

``` ;; update-grade: list-of-students name grade -> list-of-students ;; update alost by changing student-grade to grade for name ;; (define (update-student alost name grade) ... ) ```

### 4. Binary to Decimal

A `list-of-bits` is a list of numbers all of which are 0 or 1. The bits are listed from least significant to most significant, so you compute the decimal value of a list-of-bits as follows

``` ;; (cons 1 (cons 0 (cons 1 (cons 1 empty)))) ;; 1*20 + 0*21 + 1*22 + 1*23 ;; == 13 ```

Write the following function

``` ;; bin->dec: list-of-bits -> number ;; convert alob to decimal value, assuming alob starts from least ;; significant bit to most significant bit ;; (define (bin->decs alob) ... ) ```