Date: Fri, 29 Mar 2024 09:35:21 -0500 (CDT) Message-ID: <1989874751.1191.1711722921073@wiki-n2.rice.edu> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1190_737092082.1711722921070" ------=_Part_1190_737092082.1711722921070 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?
that consumes a symbol=
and a list of symbols and determines whether or not the symbol occurs in t=
he list.count-symbols
<=
span style=3D"color: rgb(0,0,0);">that consumes a list of symbols and produ=
ces the number of items in the list.count-n=
umbers
that =
counts how many numbers are in a list of numbers. [Note: the function=
merely works on inputs that are lists of numbers; it may blow up on anythi=
ng else].avg-price
. It consumes a list of toy prices and computes the ave=
rage price of a toy. The average is the total of all prices divided by the =
number of toys. Toy prices are numbers.=
span>avg-price
very easy. Do not use t=
he Racket library other than primitives mentioned in avg-price
produces an error mes=
sage as described in Guidance below. elim-exp
to eliminate expensive =
toys. The function consumes a number, called mp (short for "maximum pri=
ce") and a list of toy prices, called <=
span class=3D"variable" style=3D"color: navy;">lotp
,=
and produces a list of all those prices in lotp
that are below or equal to <=
span class=3D"variable" style=3D"color: navy;">mp
.&n=
bsp; For example(ch= eck-expect (elim-exp= 1.0 (list 2.95 .9= 5 1.0 5) (list .95 1.0)) = =3D #true
[10pts] Develop the =
function delete
to eliminate specific =
toys from a list. The function consumes the name of a toy, called =
ty
lon<=
/code>
, and produces a list of names that contains all components =
of lon
with the exception of (check-expect (delete 'robot (list 'robot 'doll<=
/span> 'dress)) (list 'doll 'dr=
ess)) =3D #true
[30pts] A list can b= e 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 r=
epresentation, we assume all elements in the list are unique; there are no =
duplicates. Develop the function power
that consumes a list of symbols los
(representing a set) and produces a list of list of symbol=
s representing 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 <=
strong>lolos
and inserts symbol <=
code class=3D"scheme">sym=
span> at the front of each list in lolos.
For example,
(ch=
eck-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))) =3D #true
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.