Lecture 26: Route finding 1

This assignment is due on Tuesday, April 12 at 11:59pm. Submit it using Handin as assignment lecture26. You only need to submit the first 3 exercises.

; A Place is String
; A Map is [ListOf Highway]
; A Highway is (make-highway Place Place)
(define-struct highway [start end])

Exercise 1. Design the function neighbors, which takes a Place and a Map and produces a list of all the Places you can get to in one step from the original Place. (Hint: process the Map.)

; A WayTree is one of:
; - (make-done Place)
; - (make-stop Place [ListOf WayTree])
(define-struct done [at])
(define-struct stop [at children])

Exercise 2. Write the template for a function that processes a WayTree. Make it look like a function called process-waytree, and do not put it in a comment. Do you see the mutual recursion?

Exercise 3. Design a function has-done? that takes a WayTree and checks if it includes a make-done. You can use ormap.

For the rest of this page, you don’t need to submit anything, but do watch the videos and try the exercises anyway. We’ll work through the material together in class.

Exercise 4. What happened when you ran the code at the end of the video?

Optional: Read Chapter 31 of the textbook.