Teaching
2500 F '11
 
Assignments
The Hand In
Set 1
Set 2
Set 3
Set 3h
Set 4
Set 4h
Set 5
Set 5h
Set 6
Set 7
Set 6h
Set 8
Set 7h
Set 9
Set 8h
Set 10
Set 9h
Set 11
Set 10h
Set 12

Problem Set 10

Due date: 11/15 @ 11:59pm

Programming Language: Intermediate Student Language with lambda


The goal of this problem set is to practice using DrRacket's loop functions. In addition we will look into local and lambda (λ) a bit more.


HtDP Problems:

22.2.2, 22.2.3, 23.2.1, 23.2.4, 24.0.7

Problem A1:

DrRacket has lots of great abstract functions for processing lists (pg. 313, Sect. 21.2, or the online version).

Given the following data definitions:

;; A Grade is: (make-grade Symbol Number)
(define-struct grade (letter num))

;; The Symbol in a Grade represents

;;    'A  >= 90
;;    'B  >= 80
;;    'C  >= 70
;;    'D  >= 60 
;;    'F  < 60

;; A [Listof Grades] ...
(define grades 
  (list (make-grade 'D 62) (make-grade 'C 79) (make-grade 'A 93) (make-grade 'B 84) 
        (make-grade 'F 57) (make-grade 'F 38) (make-grade 'A 90) (make-grade 'A 95)
        (make-grade 'C 76) (make-grade 'A 90) (make-grade 'F 55) (make-grade 'C 74)
        (make-grade 'A 92) (make-grade 'B 86) (make-grade 'F 43) (make-grade 'C 73)))

    

Design the requested functions to manipulate Grades. You must use the given list as one of your tests.

For each you may use a local function or an anonymous (lambda) function.

Note: if you do not use the DrRacket loop function mentioned, you will not recieve credit for the sub-problem!
  1. Design the function log->lon that converts a [listof Grade] into a [Listof Number] that contains just the numerical grade, using the Scheme function map.
  2. Using foldr, design the function best-grade that finds the highest Grade in a [Listof Grade].
  3. Design a function just-As that returns a list of only the 'A grades, using filter.
  4. Use andmap to design the function all-pass? that checks to see if all the Grades in a given list are not 'F.
  5. Finally design the function bonus that adds 5 to all of the Grades in a given list, and updates the letter portion of the Grade if it changes. Use map to design your function... it must return a [Listof Grade]!

last updated on Tue Nov 29 19:02:43 EST 2011generated with Racket