6.10

Assignment 5a

home work!

Programming Language BSL

Due Date: Monday at 9:00pm (Week 5)

Purpose Further practice with lists.

Finger Exercises

Exercise 1 Work through section 9.1, and do HtDP Exercise 140

Exercise 2 Work through section 9.3, and do HtDP Exercise 150

Graded Exercises

Exercise 5 Design a function eliminate, that takes a List of Numbers lon and a Number n, and constructs a new List of Numbers with all the same values as lon except for any numbers equal to n. For instance,

(check-expect (eliminate (cons 5 (cons 4 (cons 5 (cons 2 '())))) 5)
              (cons 4 (cons 2 '())))

Note: this is essentially remove-all, simplified to lists of only numbers. We have not addressed how equal? works yet, so the full flexibility of remove-all doesn’t yet make sense. Also – do not use remove-all to implement this function!

Challenge (optional): Design a function no-dups, that takes a List of Numbers, and constructs a new list with any duplicate values removed (and keeping just a single one of the copies). For example,
(check-expect (no-dups (cons 5 (cons 4 (cons 5 (cons 2 '())))))
              (cons 5 (cons 4 (cons 2 '()))))

Exercise 6 Complete the simple-net-forum assignment from Assignment 4b.