Date: Thu, 28 Mar 2024 11:31:08 -0500 (CDT) Message-ID: <827113469.1001.1711643468361@wiki-n2.rice.edu> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1000_1669807380.1711643468359" ------=_Part_1000_1669807380.1711643468359 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Due: 11:59pm, Thursday, Sep 08, 2022
100 points
For all Racket assignments in this course, set the DrRacket Language to = Intermediate Student with lambda (under = How to Design Programs). Your assignment will be graded using the = specified language level. If you use a different language level, your code = may not work when it is graded.
contains?
=
strong>that consumes a symbol and a list=
of symbols and determines whether or not the symbol occurs in the list.count-symbols
that consumes a list of symbols and produces the number=
of items in the list. [Note: the function me=
rely works on inputs that are lists of symbols; it may blow up on anything =
else].count-numbers
that counts how=
many numbers are in a list of numbers. [Note: the function merely wo=
rks on inputs that are lists of numbers; it may blow up on anything else].<=
br>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.&n=
bsp;[Hint: develop a few auxiliary functions (following the design recipe t=
o develop each auxiliary function) that you can use to make the definition =
of average-price
very easy. If the list of toy prices is empty, the fu=
nction avg-price
produces an error=
message as described in Guidance below. elim-exp
to eliminate expensive toys. The=
function consumes a number, called mp (short fo=
r "maximum price") and a list of toy prices, called lotp
, and produces a list of all those prices in mp
. For example(check-expect (elim-ex= p 1.0 (list 2.95 .95 1.0= 5) (list .95 1.0)) =3D #true
[10pts] Develop the function&=
nbsp;delete
to eliminate specific toys from=
a list. The function consumes the name of a toy, called ty=
, and a list of names, called lon
, and produces a list of names that contains all components of <=
strong>lon
with the exception of ty
. For example,
(che= ck-expect (delete'robot (list 'robot 'doll = 'dress)) (list 'doll 'dress)) =3D #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 representa=
tion, we assume all elements in the list are unique; there are no duplicate=
s. Develop the function power
that consumes a list of symbols los
(representing a set) and produces a list of list of symbols represen=
ting the power set (set of all subsets) of los
. Hint: write an auxiliary function cons-all
that consumes a symbol sym and a list of list=
of symbols lolos
and inserts symbol=
sym
at the front of each list in =
;
.
For example,
error=
function takes a single argument not two arguments as =
documented in the book. We recommend using a string (text enclosed in =
double quotation marks) like "An empty list of toy prices triggers th=
is aborting error"
as the argument. You can test the error-thr=
owing behavior of a function using check-error
which is documented in the DrRacket Help Desk.power
), write the template for the function (trivial whe=
n no recursion is involved), write the code for the function, and incl=
ude illustrative test cases for the function (using at least the examples y=
ou developed ahead of time). You should bundle the examples and test cases =
together as a block of check-expect
invocatio=
ns, which was not part of DrRacket when the First Edition of the book was w=
ritten. These tests should precede your template and code. Y=
our chosen examples should illustrate the output you expect, and the test c=
ases should produce the actual output (leave them uncommented). If the func=
tion processes an inductive type, make sure that your examples include the =
base case(s) and sample inductive cases.