Create the data definition(s) for the input of list->oos. [Do not use the Listof data abstraction.]
Solution
;; List-of-events is one of: [PT 1] ;; -- empty ;; -- (cons Event List-of-events) ;; A Event is one of: [PT 1] ;; -- 'on ;; -- 'steady ;; -- 'off
or, equivalently,
;; List-of-events is one of: [PT 2] ;; -- empty ;; -- (cons 'on List-of-events) ;; -- (cons 'steady List-of-events) ;; -- (cons 'off List-of-events)
Formulate a contract and a purpose statement for list->oos:
Solution
;; list->oos : List-of-events -> OOS [PT 1] ;; count how many times 'on, 'steady, 'off occur on l [PT 1]
Provide two distinct function examples:
Solution [PT 2]
| Given: | Wanted: | ||
| empty | (make-oos 0 0 0) | ||
| (make-oos 1 3 1) | ||