...
- Do the following programming problems:
- [10 pts] Develop the function
contains?
that consumes a symbol and a list of symbols and determines whether or not the symbol occurs in the list. - [10 pts] Develop the function
count-symbols
that consumes a list of symbols and produces the number of items in the list. - [10 pts] Develop the function
count-numbers
that counts how many numbers are in a list of numbers. - [20 pts] Develop the function
avg-price
. It consumes a list of toy prices and computes the average price of a toy. The average is the total of all prices divided by the number of toys. toy prices are numbers. [Hint: develop several auxiliary functions (following the design recipe to develop each auxiliary function) that you can use to make the definition ofaverage-price
very easy. If the list of toy prices is empty, the functionavg-price
produces an error message as described in Guidance below - [10pts] Develop the function
elim-exp
to eliminate expensive toys. The function consumes a number, called mp (short for "maximum price) and a list of toy prices, calledlotp
, and produces a list of all those prices inlotp
that are below or equal tomp
. For example(check-expect (elim-exp 1.0 (list 2.95 .95 1.0 5) (list .95 1.0)) = #true
[10pts] Develop the function
delete
to eliminate specific toys from a list. The function consumes the name of a toy, calledty
, and a list of names, calledlon
, and produces a list of names that contains all components oflon
with the exception ofty
. For example,(check-expect (delete 'robot (list 'robot 'doll 'dress empty)) (list 'doll 'dress)) = #true
[30pts] A list can be used to represent a finite set. For example,
(list 'c 'o 'm 'p)
represents the set of symbols {'c , 'o, 'm, 'p}. In such a representation, we assume all elements in the list are unique; there are no duplicates. Develop the function
power
that consumes a list of symbolslos
(representing a set) and produces a list of list of symbols representing the power set (set of all subsets) oflos
. Hint: write an auxiliary functioncons-all
that consumes a symbol sym and a list of list of symbolslolos
and inserts symbolsym
at the front of each list inlolos.
For example,
(check-expect (cons-all 'a (list (list 'c) (list 'o) (list 'm) (list 'p)) (list (list 'a 'c) (list 'a 'o) (list 'a 'm) (list 'a 'p))) = #true
- [10 pts] Develop the function
...