6.7

Assignment 14

home work!

Programming Language ISL+

Due Date Mon 3/13 at 11:59pm

Possible Points 37

Purpose To design functions that process mutually recursive data.

Graded Exercises

(define-struct room [obj north south east west])
; A Room is a (make-room Symbol Exit Exit Exit Exit)
; and represents the object in a room and the four possible exits
; An Exit is a [Maybe Room], meaning it is one of:
; – #false
; – Room
; and represents either a dead-end or a new room to walk into

Exercise 1 Design a function that outputs all of the objects in a room and the rooms you can reach from that room.

; An Sexpr is one of:
; – Symbol
; – Lexpr
 
; An  Lexpr is one of:
; '()
; – (cons Sexpr Lexpr)

Exercise 2 Problem 2: Design a function that given an Sexpr and a Symbol s determines if every symbol in the sexpr is s.

; A Path is a [List-of Nat] and describes how to traverse an Sexpr via indices.

For example, traversing 'a with the path '() would produce 'a. Traversing '((a (b (c d e) f g) h i)) with the path '(0 1 1 2) would produce 'e.

Exercise 3 Design the function find-path, which given an Sexpr and a Symbol outputs the path to the leftmost occurence of that symbol in the Sexpr. If that symbol is not in the sexpr, return #false.

Note: The design recipe is your only hope for these problems, as per usual.