6.10

Assignment 8

home work!

Programming Language ISL+Lambda

Due Date: Wednesday at 9:00pm (Week 10)

Purpose: Practice working with tree-structured data and mutual recursion.

Finger Exercises Complete exercises 1-5 from Lab 8 JSON.

Graded Exercises:

Exercise 1 Consider the following data definitions:

; A Road is one of:
; - 'dead-end
; - (make-straightaway String PositiveNumber Road)
; - Intersection
 
(define-struct straightaway [name distance more])
; INTERPRETATION: A road with some name and some amount of distance
; until the next portion of road
 
; An Intersection is a [List-of Road]

Design the function total-road-length which takes a Road and produces the total length of it and all its connected roads. Use list abstractions where appropriate.

Exercise 2 Design the function road-names which takes a Road and produces a list of all the names of roads connected to the given Road (including the name of the given Road itself if it has one). Use list abstractions where appropriate. Added to clarify: You may assume that all road names are unique.

Exercise 3 Exercise 6 in Lab 8 JSON