On this page:
New Partners!
Lambda
Multiple Complex Inputs
Before You Go...
7.5

Lab 8 Lambda and Multiple Complex Inputs

lab!

Purpose: The purpose of this lab is to get a new partner and practice using lambda as well as processing multiple complex inputs.

Textbook References: Chapter 17: Nameless Functions, Chapter 23: Simultaneous Processing

New Partners!

Goals: Get a new lab partner. Make new friends, but keep the old.

You should see a new lab partner assigned to you on the handin server. Look for the box that is titled "Teams for Homework 9" on the right-hand side. You should be able to contact this person via Microsoft Teams, but if you cannot get in contact with them please email your TAs so they can get you in touch via email.

Exercise 1 Exchange contact information with your partner. You will need to get together a lot so you are going to need to be able to talk to each other. Please give them a method of communicating with you that you will check regularly (as in, don’t just give them your email if you never check your email).

Exercise 2 Arrange a time to start working on homework 9 with your partner. It’s due on Friday so you are going to have to do it soon. It would be a good idea to establish a time to work on future homeworks as well, if you can.

Exercise 3 Re-read the policy page to refresh your memory on what to do if you are having problems with your partner. It is very important that you tell us if you are struggling to work with your partner. Otherwise we can’t help you resolve the problem.

Lambda

Exercise 4 What is the signature of the following function?
(define (my-function x y z)
  (lambda (x) (map (y z) x)))

Exercise 5 Design data to represent a SelfDrivingCar. A self-driving car has a make, a model, a color, and a function which shows how the car moves over time. The function should take one input (the current time) and produce a Posn representing the position of the car at that time.

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. The cars should be drawn on a background of some kind (you can pick one that you like). You can draw each car as a rectangle to avoid having to actually draw cars.

Multiple Complex Inputs

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")).

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.

Before You Go...

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.