6.8

Assignment 17

home work!

Programming Language ISL+

Due Date Thurs 3/23 at 11:59pm

Possible Points 46

Purpose To design functions that process multiple pieces of complex data.

Graded Exercises

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

; 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.

; A [Maybe X] is one of:
; - #false
; - X

Exercise 1 Design the function traverse that traverses the sexpr with the path and returns the resulting sexpr. If the path is not valid, return #false.

Exercise 2 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: these problems are not meant to be implemented in terms of each other. Trying to write one with the other would be disastrous in either direction. You can use them together in tests, however.

Exercise 3 Recall the data definition for an FT from the past assignment. Design the function oldest that returns the oldest person in the family tree if they exist, otherwise #false.