CSci 1301: Lab 9

You may work in groups of 2 (preferred) or individually.

What to submit

At the end of the lab please send me and your group partner(s) all your Scheme files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 9" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.

When to submit

Due Monday, December 7th, at 11:59pm. If you submit the final version during the lab, you are done.

Problem 1 (15 points)

Write a function tree that draws the following fractal "tree" picture:

A tree consists of a straight line "stem" specified by two end points (positions) and two recursively drawn branches. The end points for a branch are as follows:

The tree function takes the following parameters:


;; tree: posn posn number -> boolean
;; The function draws a fractal tree with the stem whose
;; top endpoint is end1 and bottom endpoint is end2.
;; The minimum stem length is given by min
(define (tree end1 end2 min)
;; fill in the code here
)

The above tree was drawn by the following sequence:


(define A (make-posn 400 100))
(define B (make-posn 400 700))

(start 800 800)
  
(tree A B 2)

Keep in mind that the order of endpoints matters. Use helper functions to find the endpoints of branches for the recursive calls. If your program goes into an infinite recursion sequence, stop it by pressing "stop". Save frequently since DrScheme may lose your edits if it crashes due to infinite recursion.


CSci 1301 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.