22b. List Exercises 4
Practice quiz on lists.
-
count-down-odd
: number(start) number(end) -> list of numbers. Generate a list of all of the odd numbers fromend
down tostart
(inclusive).(count-down-odd 5 10) => (list 9 7 5) (count-down-odd 5 5) => (list 5)
-
dinosaur
: list of numbers -> list of strings. Change a list of numbers, all of which will be between 0 and 7 inclusive, into a list of the corresponding letters from the worddinosaur
.(dinosaur (list 4 5 0)) => (list "s" "a" "d")
-
shaper
: list of numbers -> image. Choose an image based on the number (1=triangle, 2=square, 3=circle; pick colors and sizes you like). Randomly place the image on a 400x300 gray rectangle.Advanced bonus: the list of numbers comes in pairs - the first number selects the shape and the second number selects its size.
(shaper (list 1 50 3 20))
The call above would place a triangle of side length 50 and a circle of radius 20.