For 1.5
Two variables in a for loop, short practice.
Understand how two variables in a for loop work and be able to use in-naturals.
-
Make an
enumerate
function to number the items in a list.(check-expect (enumerate (list "Pencils" "Pens" "Markers" "Erasers")) (list "1. Pencils" "2. Pens" "3. Markers" "4. Erasers"))
-
The
scs
function takes in a list of numbers and a list of colors. It makes a list of solid squares by using the corresponding numbers and colors.(check-expect (scs (list 10 60 30) (list "orange" "blue" "pink")) (list (square 10 "solid" "orange") (square 60 "solid" "blue") (square 30 "solid" "pink")))
-
The
brc
function takes in a list of color and makes bigger and bigger circles with those colors, starting with a radius of 20 and going up by 10 each time.(check-expect (brc (list "red" "orange" "yellow" "green")) (list (circle 20 "solid" "red") (circle 30 "solid" "orange") (circle 40 "solid" "yellow") (circle 50 "solid" "green")))
Which gives:
-
Write a function to take in an image (the background) a list of
m1
structs (see below) and output a list of images - the m1’s placed on the background.(define-struct m1 (x y p)) (define ex1 (make-m1 50 75 pic:hacker)) (define ex2 (make-m1 90 20 pic:calendar)) (m1placer (empty-scene 200 100) (list ex1 ex2))
Which gives: