•
Exercise:
Creating Contracts From Examples
Exercise:
Creating Contracts From Examples
Exercise: Creating Contracts From Examples
Directions:
For each of the following collections of
Example
s, write the contract for the function above the examples.
;
:
->
(EXAMPLE (big-triangle 100 "red") (triangle 100 "solid" "red")) (EXAMPLE (big-triangle 100 "orange") (triangle 100 "solid" "orange"))
;
:
->
(EXAMPLE (purple-square 15) (rectangle 15 15 "outline" "purple")) (EXAMPLE (purple-square 6) (rectangle 6 6 "outline" "purple"))
;
:
->
(EXAMPLE (banner "Game Today!") (text "Game Today!" 50 "red")) (EXAMPLE (banner "Go Team!") (text "Go Team!" 50 "red")) (EXAMPLE (banner "Exit") (text "Exit" 50 "red"))
;
:
->
(EXAMPLE (twinkle 5 "outline") (star 5 "outline" "yellow")) (EXAMPLE (twinkle 15 "solid") (star 15 "solid" "yellow")) (EXAMPLE (twinkle 36 "outline") (star 36 "outline" "yellow")
;
:
->
(EXAMPLE (half 2) (/ 2 2)) (EXAMPLE (half 4) (/ 4 2)) (EXAMPLE (half 9) (/ 9 2))
;
:
->
(EXAMPLE (how-long? "Soccer") 6) (EXAMPLE (how-long? "Cupcakes") 8) (EXAMPLE (how-long? "Hi Mom") 6) (EXAMPLE (how-long? "Cheese pizza") 12)
Bootstrap by Emmanuel Schanzer, Emma Youndtsmith, Kathi Fisler, Shriram Krishnamurthi, Joe Politz and Ben Lerner is licensed under a
Creative Commons 4.0 Unported License
. Based on a work at
www.BootstrapWorld.org
. Permissions beyond the scope of this license may be available by contacting
schanzer@BootstrapWorld.org
.