\documentstyle [11pt,mysecs,course]{article}
\input local
\pagestyle{empty}
\problemset{6 (really!)}
\date{November 12, 1993}
\due{November 18, 1993}
\title{Converting to Tail Form}

\begin{document}
\maketitle

\problem
Do Exercises~8.5.3--8.5.4, pp.~279--281.    To assist you in
determining whether or not you have reached tail form, I have put
some help functions on the file {\tt \libdir/check-tailform.s}.  These include the
functions {\tt simple?} and {\tt tail-form?} and the special form {\tt
define-tail-form}.  The file also includes the original versions of the
functions on the problem set.

{\tt define-tail-form} works just like {\tt define}, except that it
checks to see if the body of the function being defined is in tail
form.  If it is, then the definition is installed.  If it is not, then the
definition is rejected and an error message is printed.  Define your answers
using {\tt define-tail-form} to demonstrate that they have the correct
form.  {\tt define-tail-form} is moderately simple-minded about which
special forms it recognizes.  These are: {\tt if}, {\tt lambda}, {\tt
record-case}, {\tt cond}, and {\tt letrec}.  Therefore, you should write your
programs using these as the only special forms.  

The file also contains a similar special form called {\tt define-simple} if
you feel the need to define a new simple function.  I think I have included
in the list {\tt **simples**} all the simple system functions you will need,
but you may add some additional ones if you absolutely must.  

[Note:  The following questions may or may not be required, depending on how
far we get in lecture on November 12]

\problem
Complete the process of going from an arbitrary function
to first-order form by converting the continuations in {\tt remove*} to data
structures.  Your result should be a tail-form, first-order program, like the
ones in section~9.1.  Verify that your answer is still in tail form by
defining both your new version of {\tt remove*} and {\tt apply-continuation}
using {\tt define-tail-form}.  

\problem
Convert your answer to the previous problem to imperative form.  Your answer
should be an imperative-form program, like the ones in section~10.1.

\end{document}


