\documentstyle{article}
\newcommand{\eo}{$exp_{1}$}
\newcommand{\et}{$exp_{2}$}
\begin{document}
\setlength{\parindent}{0 in}
\hfill\begin{tabular}{l}
Marc Horowitz \\
6.001 \\
Problem Set 1 \\
February 17, 1989 \\
\end{tabular}
\par\vspace{0.75 in}
{\large \bf Part I}
\par\vspace{0.4 in}
{\bf Exercise 1.1}
\begin{verbatim}
==> (+ 7 8 9)
24

==> (> 10 9.7>
t

==> (- (* 2 5) (/ 16 10))
8.4

==> (define double (lambda (x) (* x 2)))
double

==> double
compound-procedure

==> (define c 4)
c

==> c
4

==> (double c)
8

==> c
4

==> (double (double (+ c 5)))
36

==> (define times-2 double)
times-2

==> (times-2 c)
8

==> (define d c)
d

==> (= c d)
t

==> (if (= (* c 6) (times-2 d))
	(< c d)
	(+ c d))
8

==> (cond ((>= c 2) d)
	  ((= c (- d 5)) (+ c d))
	  (else (abs (- c d))))
4

==> (define try (lambda (x) (x 3)))
try

==> (try double)
6

==> (try (lambda (z) (* z z)))
9
\end{verbatim}
\par\vspace{0.3 in}
{\bf Exercise 1.2}
\par\vspace{0.3 in}
\begin{tabular}{rcl}
\{  & ((lambda (x) ((lambda (y) (- y x)) \eo)) \et) & \} \\
{[} & \fbox{PROC (x) ((lambda (y) (- y x)) \eo)} \fbox{12} & {]} \\
\{  & ((lambda (y) (- y \fbox{12})) \eo) & \} \\
{[} & \fbox{PROC (y) (- y \fbox{12})} \fbox{5} & {]} \\
\{  & (- \fbox{5} \fbox{12}) & \} \\
{[} & \fbox{sub} \fbox{5} \fbox{12} & {]} \\
\multicolumn{3}{c}{\fbox{-7}}
\end{tabular}

\vspace{0.2 in}

\begin{tabular}{rcl}
\{  & ((lambda (y) ((lambda (x) (- y x)) \et)) \eo) & \} \\
{[} & \fbox{PROC (y) ((lambda (x) (- y x)) \et)} \fbox{5} & {]} \\
\{  & ((lambda (x) (- \fbox{5} x)) \eo) & \} \\
{[} & \fbox{PROC (y) (- \fbox{5} x)} \fbox{12} & {]} \\
\{  & (- \fbox{5} \fbox{12}) & \} \\
{[} & \fbox{sub} \fbox{5} \fbox{12} & {]} \\
\multicolumn{3}{c}{\fbox{-7}}
\end{tabular}

\vspace{0.2 in}

\begin{tabular}{rcl}
\{  & ((lambda (x y) (- x y)) \et \eo) & \} \\
{[} & \fbox{PROC (x y) (- x y)} \fbox{12} \fbox{5} & {]} \\
\{  & (- \fbox{12} \fbox{5}) & \} \\
{[} & \fbox{sub} \fbox{12} \fbox{5} & {]} \\
\multicolumn{3}{c}{\fbox{7}}
\end{tabular}

\vspace{0.2 in}

\begin{tabular}{rcl}
\{  & ((lambda (y) (lambda (x) (- y x)) \eo) \et) & \} \\
{[} & \fbox{PROC (y) (lambda (x) (- y x)) \eo} \fbox{12} & ] \\
\{  & (lambda (x) (- \fbox{12} x)) \eo) & \} \\
{[} & \fbox{PROC (x) (- \fbox{12} x)} \fbox{5} & ] \\
\multicolumn{3}{c}{\fbox{5}}
\end{tabular}

\vspace{0.2 in}

\begin{tabular}{rrclcl}
\{  &     & (((lambda (x) (lambda (y) (- y x))) \eo) \et) &     &           & \} \\
(   & \{  & ((lambda (x) (lambda (y) (- y x))) \eo)       & \}  & \et       & ) \\
(   & {[} & \fbox{PROC (x) (lambda (y) (- y x))} \fbox{5} & {]} & \fbox{12} & ) \\
(   & \{  & (lambda (y) (- y \fbox{5}))                   & \}  & \fbox{12} & ) \\
{[} &     & \fbox{PROC (y) (- y \fbox{5})}                &     & \fbox{12} & {]} \\
\{  &     & (- \fbox{12} \fbox{5})                        &     &           & \} \\
{[} &     & \fbox{sub} \fbox{12} \fbox{5}                 &     &           & {]} \\
    &     & \fbox{7}                                      &     &           & 
\end{tabular}
\par\vspace{0.3 in}
{\bf Exercise 1.3}
\begin{verbatim}
(/ (+ 3 2 (- 1 (- 5 (+ 2 (/ 3 4)))))
   (* (- 7 3) (- 1 8)))
\end{verbatim}
\par\vspace{0.3 in}
{\bf Exercise 1.4}
\par\vspace{0.3 in}
The function \verb+sqrt-iter+ will not work because all four parts of the
combination must be evaluated before \verb+sqrt-iter+ can be called.
Unfortunately for Alyssa, evaluating the combination requires evaluating
another \verb+sqrt-iter+.  Because all parts of the combination must be
evaluated, the function will never return.  The special form \verb+if+
avoids this because all of its arguments will not be evaluated each time.
\par\vspace{0.6 in}
{\large \bf Part II}
\par\vspace{0.4 in}
{\bf Problems 1, 2, and 3}\hspace{0.2 in}See printouts at the end.
\par\vspace{0.3 in}
{\bf Problem 4}
\par
\[ {\cal L} = 3L(\frac{4}{3})^n \]

In the base case, n=0, the curve is a triangle with sides of length $L$.
For each level greater than $0$, every segment in the curve is replaced
with $4$ segments $\frac{1}{3}$ the length of the original.  This makes
the entire curve $\frac{4}{3}$ times longer.  So to get the length of a
curve of level $n$, mutiply $3L$ by $\frac{4}{3}$ once for each level.
This leads for the equation for $\cal L$ which I have given.
\par\vspace{0.3 in}
{\bf Problem 5}\hspace{0.2 in}
\par
\begin{verbatim}
==> (define f-one (lambda (s) 1))
F-ONE

==> (define (ssl g n) (snowflake-length 100 n f-one g))
SSL

==> (define g (lambda (x) (+ (* x x) (* 2 x) 3)))
G

==> (ssl 0 g)
300

==> (ssl 1 g)
2400

==> (ssl 2 g)
35200

==> (ssl 3 g)
844800

==> (ssl 4 g)
3.04128e7

==> (ssl 0 sqrt)
300

==> (ssl 1 sqrt)
400

==> (ssl 2 sqrt)
754.247

==> (ssl 3 sqrt)
1741.86

==> (ssl 4 sqrt)
4644.96

==> (define g (lambda (s) (if (= s 0) 1 (/ 1 s))))
G

==> (ssl 0 g)
300

==> (ssl 1 g)
400

==> (ssl 2 g)
266.667

==> (ssl 3 g)
118.519

==> (ssl 4 g)
39.5062
\end{verbatim}
\par\vspace{0.3 in}
{\bf Problem 6}
\par
\verb+PEN-MOVED+ is returned by calls to \verb+snowflake+
because \verb+snowflake+ returns what the last call to
\verb+side+ returns, which is the return value of
\verb+plot-line+.  This return value is \verb+PEN-MOVED+.
\par\vspace{0.3 in}
{\bf Finally}
\par
I spent about 2 hours in lab and about 4 hours total.
\end{document}
