Referenced from lesson Domain and Range

Can you guess the contract for a function just by seeing how it’s used? Try to match each Expression in the left column with a Contract in the right column that describes the function being used. Some expressions or contracts might not have a match.

Math Expression Contract

(big-star "purple")

1

A

; message-cost : Number -> Number

(big-star 25 "gold")

2

B

; big-star : String -> Image

(message-cost 15)

3

C

; choose-flavor : String String -> String

(message-cost "where are you?")

4

D

; big-star : Number String -> Image

(show-score "Red Sox" 6 "Cardinals" 4))

5

E

; message-cost : String -> Number

(find-winner "Red Sox" 4 "Cardinals" 6)

6

F

; prefer-flavor : String String -> Number

(pick-flavor "vanilla" "oreo" "mint")

7

G

; find-winner : String Number String Number -> String

(prefer-flavor "lemon" "lime")

8

H

; show-score : String Number String Number -> Image

I

; pick-flavor : String String String -> Image

J

; show-score : String String -> Image

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap:Algebra by Emmanuel Schanzer, Jen Poole, Ed Campos Jr, Flannery Denny, and Dorai Sitaram 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.