8.10

Homework 4b

home work!

Programming Language #lang htdp/isl

MUST BE DONE SOLO

Due Date Thu at 9:00pm (Week 4)

NOTE: this assignment is somewhat more involved than previous "b" assignments. We encourage you to start early!

Purpose Practice list functions

Exercises

Exercise 1 Design the function "interleave", that takes two list of numbers and produces a single list of their items, alternating from each list, beginning with the first. If the lists have different lengths, just finish with all the remaining items of the longer list.

Exercise 2 Design the function "prime-factors" that consumes a positive integer and produces a list of the prime factors of that integer in ascending order (including duplicates). You may assume that the input is an integer greater than one.

Exercise 3 Design the function "intersection", which given a non-empty list of lists of numbers returns the numbers that appear in every sublist. Return the elements in the order they appear in the first list they are present in. Assume each inner list does not repeat numbers. Note that while the outer list is non-empty, inner lists may be empty.

Exercise 4 Design the function "all-contained-in?" that takes two lists of lists of numbers and determines whether every list in the first list is contained somewhere in the second.

Exercise 5 Design the function "powerlist" which returns all possible sublists of a list of numbers. A sublist of a list is any list whose elements are all present in the initial list and appear in the same relative order. Assume the initial list given to "powerlist" contains no duplicates.

Note here that while the order of each sublist is specified, the order in which the sublists appear in the result list is *not*. Your tests should be flexible enough to allow for sublists to occur in any order. Unlike in previous autograded assignments, there are multiple different instructor implementations. Your tests should not fail for any of them. To do so, the "all-contained-in?" predicate designed in Exercise 4 should be utilized.