Date: Thu, 28 Mar 2024 20:22:39 -0500 (CDT) Message-ID: <1362857561.1069.1711675359489@wiki-n2.rice.edu> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1068_1673286520.1711675359487" ------=_Part_1068_1673286520.1711675359487 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Submit via OWLSPACE in a single (.ss
or .rkt
) =
file that is runnable in DrScheme (so all expository answers must be enclos=
ed in comment blocks or commented out using semi-colons.s into one file and=
submit this one compressed file. We did not deduct any points for using th=
e wrong format on HW01 but we will deduct points for this error on this ass=
ignment. Begin each problem with a comment line containing the number of th=
e problem.
The type "natural number" (N) in this assignment means =
the natural-number type defined in the text in Section 11.1. Your =
file should include a data definition for N. Unless the pr=
oblem statement stipulates otherwise, the only built-in operations=
you may use with values of this type or variants (such as natural>=
;=3D1
) are the constructors, accessors, and recognizers for the type=
and the equal?
(or =3D
}) operation. For =
N, the constructor is add1
; the accessor is su=
b1
, and the recognizers are zero?
and positive?=
code>.
For variants, the constructor is typically add1
(unless the v=
ariant consists of multiples of m > 1
[such as the even num=
bers]), the accessor is typically sub1
, and the recognizers ar=
e typically (equal? ... k)
, where k
is the base n=
umber, and (> ... k)
.
deep-list
from the text. Be sure to=
provide your own function template for deep-list
and to write=
template instantiations for depth
and make-deep
.=
natural>=3D1=
. In addition to the constructors, accessors, recognizers, and equal?
, you may use the library functions remainder
an=
d *
. Hint: define an auxiliary function is-divisible-by=
of two inputs p
and q
(using the re=
mainder
library function) that determines if p
is divis=
ible by q
(i.e., p/q is a whole number).prime?
is easy after doing the first. Do not worry abo=
ut optimizing the search for a divisor for n by bounding the search to numb=
ers less or equal to (integer-sqrt n)
; for simplicity, the sqrt
library functions are forbidde=
n in this exercise.arrangements<=
/code> that returns a list containing all of the arrangements (permutations=
) of the input word. This function is described in detail in the text and t=
he code for it is given to you in the statement of problem=
12.4.1. You are expected to present this answer in your program file as if=
you developed it, including supporting test data.
insert-everywhere/in-all-words
is more easily understood given the following examples:=20
(insert= -everywhere/in-all-words 'd (list (list 'e 'r))) =3D (list (list 'd 'e 'r) = (list 'e 'd 'r) (list 'e 'r 'd)) (insert-everywhere/in-all-words 'd (list (list 'e 'r) (list 'r 'e))) =3D (list (list 'd 'e 'r) (list 'e 'd 'r) (list 'e 'r 'd) (list 'd 'r 'e) (li= st 'r 'd 'e) (list 'r 'e 'd))
insert-everywhere
w=
here (insert-everywhere s w)
inserts the letter s
=
in each possible position in the word w
, including before=
and after all letters of w
. Note the difference=
in the type contracts for insert-everywhere
and insert-=
everywhere/in-all-words
.arrangements
computes all of the arrangements
function because it is cool an=
d developing insert-everywhere/in-all-words
is the bulk of the=
work involved in developing arrangements
.