Exercise:   Matching Contracts and Examples

Exercise: Matching Contracts and Examples

Directions: Match each Example on the left with the Contract on the right. NOTE: Multiple examples may match to the same contract!
  •  

    (EXAMPLE (match 30 "red")
             (+ 30 (string-length "red")))
     
     

    ; match : image -> image

  •  

    (EXAMPLE (match 10 "blue")
             (+ 10 (string-length "blue")))
     
     

    ; match : number string -> number

  •  

    (EXAMPLE (match (abs -4) "45")
              4)
     
     

    ; match : number image -> image

  •  

    (EXAMPLE (match (triangle 20 "solid" "blue") 
                    3)
             (scale 3 (triangle 20 "solid"
                                   "blue")))
     
     

    ; match : image number -> image

  •  

    (EXAMPLE (match (circle 10 "solid" "orange") 
                    22)
             (scale 22 
                    (circle 10 "solid" "orange")))
     
     

  •  

    (EXAMPLE (match 5 (star 20 "solid" "red"))
             (rotate (- 90 5) 
                     (star 20 "solid" "red")))
     
     

  •  

    (EXAMPLE (match (circle 20 "outline" "gold"))
             (rotate 37 (circle 20 "outline" 
                                  "gold")))
     
     

  •  

    (EXAMPLE (match (circle 10 "solid" "green"))
             (rotate 37 
                     (circle 10 "solid" "green")))
     
     

 
These materials are OUT OF DATE! To get the latest version of the materials, visit https://www.BootstrapWorld.org/materials