Lab 3: Conditional Eval
Choose the initial Head and Hands, and get started!
Temperature and Composition
Ex 1: Define a function what-temp that consumes a number (in degrees Fahrenheit) and produces one of three strings: "cold" for cold temperatures (say, less than 45), "hot" for hot temperatures (at or greater than 75), and "comfy" for anything in between.
Ex 2: Some international students (or just anyone tired of the Imperial system) may prefer to use Celsius for their input temperatures. Define a function celsius->fahrenheit that converts a number from degrees Celsius to degrees Fahrenheit. Search for the conversion online if you don’t know it off-hand.
Ex 3: Define a function what-temp/celsius that takes in a number (in degrees Celsius) and returns the same three strings as in Ex 1 for the appropriate temperature ranges.
Chip the Cheap Sheep
Swap Head and Hands.
Meet Chip! Chip likes to run.
0 1 2 3
Ex 4: Define a function which-chip that, given a number between 0 and 3, returns the properly indexed image above.
Ex 5: Define a function time->chip that, given any non-negative number, returns an appropriate frame of Chip’s stride. For any N, N+1 should return the next indexed image (looping back to the first after the fourth image is returned). Animate Chip’s graceful stride by passing time->chip to animate.
Hint: There may be a helpful, built-in numeric function to make time->chip easy to implement with which-chip.
Ex 6: Define a function run-chip-run that, (like time->chip) given a non-negative number, returns the appropriate frame of Chip’s stride above, but also moves Chip right-to-left across a 1000px-wide scene. Show one of your TAs this animation and you get to leave early!