Module 06
Last updated: Thu, 19 Feb 2015 14:31:22 -0500
Readings
HTDP/2e, Part IV, Chapters 22-27
Supplemental Materials
Read these guidlines about when to use local.
Pre-lecture
Read the Readings and Supplemental Materials.
Goals
Understand how to write mutually-referential data definitions and accompanying templates and functions.
In-class
1 Mobile
Design a program to help artists create mobile sculptures.
A mobile consists of either a single hanging, weighted sculpture,
or a balanced beam with multiple mobiles hanging from each side of the beam:
Specifically, create a data definition Mobile that represents mobiles.
Then write the function below to determine if a mobile is balanced.
A mobile that is a single, hanging sculture is balanced.
In general, a mobile is balanced if the weights on both sides of a
join point are the same and every mobile on both sides is balanced;
see above for two balanced mobiles. For now, ignore the distance to the
join point in your calculations.
; mobile-balanced? : Mobile -> Boolean ; Returns true if m is balanced ... ; Examples: ??? ; Strategy: ??? (define (mobile-balanced? m) ...)
After you are done, think about how you should incorporate the distance
to the join point in your data and calculations, so that your function
would accurately predict real-world balanced mobiles.
2 Extra In-class Exercises
Chapter 22.1, exercises 251-254