The relevant properties of a lion are, in order
Here is a data definition and structure definition:
; A lion is ; (make-lion num sym) (define-struct lion (teeth ate))
Implement the function more-scary-lion, which takes a lion and produces a lion with two additional teeth (but the same stomach contents).
Design a representation for tigers, where the relevant properties of a tiger are
Use tiger as the name of your structure, and put the fields in the above order.
Implement the function more-scary-tiger, which takes a tiger and produces a tiger (with the same fur pattern and stomach contents) whose claws are one centimeter longer.
Design a representation for bears, where the relevant properties of a bear are
Use bear as the name of your structure, and put the fields in the above order.
Implement the function more-scary-bear, which takes a bear and produces a bear (with the same fur color) that hasn't eaten recently.
Define the data type oz-animal, which is a lion, tiger, or bear.
Implement the function more-scary-oz-animal, which takes an oz-animal and produces a scarier animal (as above).
Define the function feed-oz-animal that takes two arguments: an oz-animal and a sym for a person's name. The result should be an oz-animal that just ate the person whose name is given.
Define the function rescue-from-animal that takes an oz-animal and returns an oz-animal that hasn't recently eaten anyone.
Hint: the answer should be especially short, and it should use the name 'no-one.
An Oz scene consists of one person and one oz-animal. It is represented as an oz-scene:
; An oz-scene is ; (make-oz-scene sym oz-animal) (define-struct oz-scene (person animal))
Implement the function more-scary-scene, which takes an oz-scene and produces one with a scarier animal and the same person.
An Oz scene moves the next scene as follows:
Implement the function next-scene, which takes an oz-scene and returns the next oz-scene according to the rules above.
Don't forget to break up the problem into smaller pieces. For example, you might find am animal-ate function useful (that takes an animal and returns the person that the animal recently ate).
Last update: Wednesday, September 3rd, 2003mflatt@cs.utah.edu |