| 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!
- 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.
- Using
foldr, design the function best-grade
that finds the highest Grade in a [Listof
Grade].
- Design a function
just-As that returns a list of only
the 'A grades, using filter.
- Use
andmap to design the
function all-pass? that checks to see if all the
Grades in a given list are not 'F.
- 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]!
|