On this page:
Multiple Complex Inputs
8.16

Lab 9 Multiple Complex Inputs🔗

lab!

Purpose: to practice processing multiple complex inputs.

Textbook References: Chapter 23: Simultaneous Processing

Multiple Complex Inputs🔗

Exercise 1 Design the function alternate which, given two lists produces a list of alternating elements from each list (and if one list runs out of elements you should place all the remaining elements in the other list at the end). Some tests have been supplied for clarity.

Do not use any list abstractions from ISL for this exercise.

(check-expect (alternate '() '()) '())
 
(check-expect (alternate '() (list "a" "b")) (list "a" "b"))
 
(check-expect (alternate (list 1 2 3) '()) (list 1 2 3))
 
(check-expect (alternate (list 1 2) (list "a" "b" "c"))
              (list 1 "a" 2 "b" "c"))

Exercise 2 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:
(check-expect (cross-product (list 1 2) (list "a" "b" "c"))
              (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.

Exercise 3 Homework 8-related Exercises The rest of the problems for this lab are related to Homework 8, and are available here: lab9-hw8-exercises.txt. Download the file, and cut-and-paste the contents into your labwork after the answers to the first exercises, complete the problems, and submit.