1. This
set
of
exercises
has
to
do
with
programming
with
recursively
constructed
lists.
In
spirit,
the
exercises
build
upon
the
Nat
methods
you
wrote
for
the
previous
homework
assignment.
I
am
expecting
that
some
of
you
will
find
some
of
these
methods
tricky
to
implement
-‐-‐
some
of
them
are
like
little
puzzles
-‐-‐
but
I
can't
anticipate
just
where
the
difficulties
will
arise.
Please
post
to
piazza
as
you
encounter
hurdles.
Note
that
each
method
has
a
simple
recursive
solution.
My
implementations
(admittedly
making
frequent
use
of
the
inline
conditional
form
? :
in
place
of
if/else
blocks)
are
all
one
line
or
possibly
two
where
I've
decided
to
declare
a
local
variable.
Your
methods
don't
need
to
be
that
concise
to
be
correct,
but
if
you
find
yourself
writing
many
lines
of
code
for
any
method,
you
might
reconsider
your
approach.
First,
here
is
an
implementation
of
a
PairOf
class
that
is
generalized
over
a
type
T
Next,
here
is
an
interface
for
predicates
on
items
of
some
variable
type
T.
Each
predicate
implements
one
method,
a
true-‐or-‐false
test
on
an
item
of
type
T.
The
need
for
objects
of
type
Pred
will
become
clear
later
in
this
writeup.
2.
Now,
a
generic
interface
for
"master's
program
linked
lists"
(which
we'll
abbreviate
MLL).
A
few
of
these
methods
were
implemented
on
the
board
in
class,
but
most
weren't.
For
the
methods
that
return
lists,
consult
the
implementation
of
append
given
in
lecture,
which
gives
an
idea
how
to
go
about
deconstructing
the
problem
recursively.
4.
To
complete
the
assignment,
complete
the
implementation
by
writing
Nil
and
Cons
(as
in
class)
and
provide
a
tester
file.
The
first
lines
of
the
Nil
and
Cons
files
are
as
follows:
Lest
you
get
the
wrong
impression,
type
variables
need
not
always
be
named
T.
Like
i
for
integers
in
for
loops,
it's
just
the
most
common
variable
name,
by
far.