Important Note:: Total-Dur
Important Note:: Total-Dur
IMPORTANT NOTE:
The template for processing a list:
(define (fn-list-name alist)
(cond
[(empty? alist) ]
[else ... (first alist) ...(fn-list-name (rest alist)) ...]))
This lab makes use of the following structure and data definitions:
(define-struct event (type dur))
;; An event is a structure (make-event t d), where
;; * t is a symbol (the type of event) and
;; * d is a positive integer (the duration in minutes).
1. Create a function total-dur that consumes a list of events and produces the total duration
in minutes.
2. Create a function values that consumes a symbol (a suit) and a list of distinct cards and
produces a list of numbers, that is values of cards from the original list that have the
specified suit.
3. Create a function update-times that consumes a list of clocks and a natural number m (a
number of minutes) and produces a list of updated clocks, each m minutes later on the same
day (you can assume none of the new times go past midnight to the next day).
4. Create a function max-card that consumes a nonempty list of cards and produces a card
with the maximum value of any card in the list (if there is more than one, the one appearing
closest to the end of the list).
5. Create a function average-length that consumes a list of events and a
symbol (the
type of the event) and produces the average duration of events of that type.
If a list is
empty or there are no events of a particular type, the average will be zero.
Be careful
not to divide by zero!