Exercise: Matching Expressions and Contracts

Directions: 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.
  • (big-star "purple")

    ; big-star : number string -> image

  • (big-star 25 "gold")

    ; message-cost : string -> number

  • (message-cost 15)

    ; message-cost : number -> number

  • (message-cost "where are you?")

    ; show-score : string string -> image

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

    ; show-score : string number -> image

  • (show-score "Red Sox" "Cardinals" 5 5)

     

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

    ; prefer-flavor : string string -> number

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

    ; choose-flavor : string string -> string

  • (prefer-flavor "lemon" "lime")

    ; pick-flavor : string string string -> image