Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks, and Grading Guidelines. Above all, keep your work neat and honest.
Reminder that templates are required for each data definition that you use this week.
(8 pts) In class, we discussed two data definitions for family trees (reproduced below). Some programs are easier to write using one data organization rather than the other. To explore this, write the following program in each of the two definitions (4 pts each).
Write a program find-siblings which consumes a list of family trees and a symbol and produces a list of symbols. The symbols in the output list are the names of the siblings of the person named in the input symbol. You may assume that a name appears at most once in a family.
Notes: This problem uses a list of family trees so that we may have multiple entry points into each family, as discussed in class (for example, in the descendant tree on page 217 of the text, the list would contain the parent structures for Carl, Bettina, and Fred). As a reminder, here are the two data definitions for family trees (the text provides sample pictures of both types of trees, on pages 197 and 217, respectively).
A ftn (for family tree node) is either - empty, or - (make-child na f m yr ec) where na is a sym, f and m are ftn, yr is a num and ec is a sym (define-struct child (name father mother year eye-color))
A parent is a structure (make-parent n y e loc) where n and e are symbols, y is a num, and loc is a list-of-children. (define-struct parent (name year eye-color children)) A list-of-children is either - empty, or - (cons p loc) where p is a parent and loc is a list-of-children
Write a program gen-site-tree which consumes a string and produces an html-list. The input string is the path to the directory for which you want to generate the site-tree. The resulting html-list contains the site-tree. For the link to each file, use the file's name as the link text. For the URL, the library provides a function get-path-to-file, which consumes a symbol (file name) and a directory structure and produces a string. Use the result of get-path-to-file as the URL. See the third note below on what the library provides for information regarding the directory that you must pass to get-path-to-file.
The library hwk4-lib.ss provides
the data definitions for html (same as in previous assignments)
the data definition for directories (the directory definition used is the same as the third model of files and directories given on page 233 of the text)
a function create-dir, which takes a path and returns a dir structure for the directory hierarchy starting at the input path. Note that get-path-to-file needs to take the entire directory produced from create-dir as its input.
Test your program using the library function produce-test-page, which consumes an html-object and a filename, and writes a web page containing the object to the named file.
|Kathi Fisler||This page was generated on Mon Sep 27 17:01:35 CDT 1999.|