| 8 POINTS |
Problem$^a$ 3. Here are data definitions from an environmental surveillance program for rivers:
(define-struct end (location distance in)) (define-struct joint (location distance left right)) (define-struct well (location)) ;; A River (system) is a: ;; -- (make-end Symbol Number Tributary) ;; A Tributary is one of: ;; -- (make-well Symbol) ;; -- (make-joint Symbol Number Tributary Tributary)
Draw ``arrows' into the data definitions. Provide one data example for River that involves all three structures. Develop as many templates as needed for this system of data definitions.
Solution [PT 1: data example]
(make-end 'A 10
(make-joint 'B 20
(make-well 'C)
(make-well 'D)))
[PT 7: 2 for two templates, 3 for arrows, 1 for all sel, 1 for cond]
;; pro-river : River -> ???
(define (pro-river r)
... (end-location r) ... (end-distance r)
... (pro-tributary (end-in r)) ...)
;; pro-tributary : Tributary -> ???
(define (pro-tributary t)
(cond
[(well? t) ... (well-location t) ...]
[else ... (joint-location t) ...
... (joint-distance t) ...
... (pro-tributary (joint-left t)) ...
... (pro-tributary (joint-right t)) ...]))