Purpose: The purpose of this lab is to practice practice using lambda as well as processing multiple complex inputs.
Exercise 1 Provide a signture and at least 2 tests for the following function:
Exercise 2 Provide a signture and at least 2 tests for the following function:
Please submit the above exercise to the handin server by 10pm EDT on the day of lab.
Exercise 3 Consider the following data definition. Use lambda to make several examples of TravelFuncs.
Exercise 4 Consider the following data definition. Make several examples of SelfDrivingCars.
(define-struct sdc [make model color drive]) ; A SelfDrivingCar is a (make-sdc String String Color TravelFunc) ; and represents a self-driving car where ; - make is the make of the car ; - model is the model of the car ; - color is the color of the car ; - drive is a function which tells you where the car will be at a given point in time
Exercise 5 Design a function show-car which takes a SelfDrivingCar, a time (a Number), and a background Image. It draws the car at the correct position for the given time onto the given background.
Exercise 6 Design a function show-all-cars which takes a list of SelfDrivingCars and a time (a Number) and draw all the cars in the list at the correct position for the given time. You must use a list abstraction and a lambda function to define your function.
Exercise 7 Design the function pair-lists which, given two lists, produces a list of the pairs of elements in the same position. Each pair will be represented by a list of two elements. If one list runs out of elements, the remaining elements in the other list should be ignored. For example, (pair-lists (list 1 2) (list "a" "b" "c")) should produce (list (list 1 "a") (list 2 "b")). Do not use list abstractions.
Exercise 8 Design the function cross-product which, given two lists, produces a list of all possible pairs of elements. Each pair will be represented by a list of two elements. For example, (cross-product (list 1 2) (list "a" "b" "c")) should produce (list (list 1 "a") (list 1 "b") (list 1 "c") (list 2 "a") (list 2 "b") (list 2 "c")). The ordering of the list does not matter. Do not use list abstractions.
Exercise 9 Rewrite cross-product using list abstractions and lambda.
If you had trouble finishing any of the exercises in the lab or homework, or just feel like you’re struggling with any of the class material, please feel free to come to office hours and talk to a TA or tutor for additional assistance.