EECS 111 Lecture Notes - Lecture 18: Mutation, Foreach Loop

64 views9 pages

Document Summary

Because the parent type of a cat is an animal, they have a name, weight, age. How constructors change with structs with parent types. Selectors (pixel is the name of the cat) (animal-name pixel) --> parent type is used in the selector for fields that com (animal-weight pixel) (animal-age pixel) (cat-sleeping-spot pixel) --> this one is different. When making a type name with parent types, make sure to put parent types first. If a dog"s parent type is animal, a dog is (make-dog string number number string (define-struct (dog animal) [best friend]) [else (+ (animal-weight (first loa)) (zoo-weight (rest loa)))])) Takes an animal as input and returns void (the point of this procedure is the side e. Takes an animal and ages that animal by 1 year. Exclamation point is a coding standard that indicates there is a side effect (define (make-animal-older! A) come from the parent type tring) de effect) (define (make-animal-older!

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents