\documentclass[twocolumn]{article}

\usepackage{fullpage}
\usepackage{palatino}

\begin{document}

\title{6.001 Tutorial 1}
\author{David Ziegler}
\date{September 13, 2004}
\maketitle

\section{General Information}
Your TA: David Ziegler \\
Email: \verb+david@ziegler.ws+ \\
Cell: 617-429-6685 \\
Tutorial webpage: \\
\verb+  http://david.ziegler.ws/6.001/+

\section{6.001 Lab}
\begin{itemize}
\item 34-501, 50 Vassar Street (for ordering food late at night)
\item Outer door combination: 47519
\item Inner door combination: 72962*
\item Friendly lab assistants are available!
\end{itemize}

\section{Due Dates}
\begin{itemize}
\item Problem set 1 --- due \textbf{tomorrow} at midnight!  Don't wait
  until the last couple hours to turn it in, because the server gets
  slow.
\item Lecture 3 problems --- due \textbf{Wednesday} at 10 am.
\item Lecture 4 problems --- due \textbf{Friday} at 10 am.
\item Project 0 --- due \textbf{Wednesday} at 6 pm.
\end{itemize}

\section{Scheme}
\begin{itemize}
\item Why do we like Scheme?
\item \textbf{Very} simple syntax -- you can learn it in under an
  hour.
\item Focus on learning \emph{programming}, not \emph{language}.
\item It's actually used in the real world!  Yahoo! Store, artificial
  intelligence, ...
\end{itemize}

\section{Types of Expressions}
\begin{itemize}
\item \textbf{Constants}:\\
  \verb+42+, \verb+"hello"+, \verb+3.1415926535+...

These are self evaluating -- the value is the constant itself.

\item \textbf{Names}:\\
  \verb+a+, \verb+-+, \verb+-$$~foo+

The value of a name is found by looking up the name in the table.
Later on in the course, we'll explain how this really works.

\item \textbf{Combinations}:\\
  \verb+(procedure argument argument ...)+

To find the value of a combination, first evaluate each subexpression
(in any order).  Then, apply the value of the procedure to the values
of the arguments.

\item \textbf{Special Forms}:\\
  \verb+(define name value)+\\
  \verb+(if test consequent alternate)+\\
  \verb+(lambda (arg1 arg2 ...) body)+

Each special form has a different rule for evaluation.
\end{itemize}

\section{\texttt{define}}
\verb+(define name value)+

To evaluate a \verb+define+ expression, first evaluate \verb+value+,
then stick a new entry in the table, with \verb+name+ and the value of
\verb+value+.  This \emph{binds} the \verb+name+ to the value of
\verb+value+.

\section{\texttt{lambda}}
\verb+(lambda (arg1 arg2 ...) body)+

The list of parameters can have any number of names -- even zero.  The
body is a bunch of Scheme expressions (but at least one).  When the
procedure is applied, each expression is evaluated, and the value of
the last one is returned.

To evaluate a \verb+lambda+, we create a procedure object and return a
pointer to it, but \emph{do not evaluate the arguments or the body}.
The body is only evaluated when the procedure is applied later.

\section{Syntactic Sugar}
\begin{verbatim}
(define name
  (lambda (arg1 arg2 ...) body))
(define (name arg1 arg2 ...) body)
\end{verbatim}

Since you often need to do the first form, Scheme provides
\emph{syntactic sugar} for this pattern.  The two are
\emph{identical}.

\section{\texttt{if}}
\verb+(if test consequent alternate)+

To evaluate an \verb+if+ expression, evaluate the \verb+test+.  If the
value is \emph{not} \verb+#f+, the value of the entire expression is
the value of the \verb+consequent+.  Otherwise, the value is the value
of the \verb+alternate+.

Why does \verb+if+ need to be a special form?

\section{Problems!}
\begin{verbatim}
;; This procedure should return the
;; larger of the two quadratic roots
;; of the quadratic ax^2+bx+c
(define quadratic-root
  (lambda (a b c)



\end{verbatim}

\begin{verbatim}
;; This procedure should return the
;; remainder of x divided by y
(define remainder
  (lambda (x y)



\end{verbatim}

\newpage

\begin{verbatim}
;; This procedure should return #t
;; if x is divisible by y, and #f
;; otherwise
(define divisible?
  (lambda (x y)

\end{verbatim}

\begin{verbatim}
;; This procedure should return the
;; nth fibonacci number
;; (fibonacci 0) => 0
;; (fibonacci 1) => 1
(define (fibonacci n)




\end{verbatim}

\begin{verbatim}
;; This procedure should return n
;; factorial
;; 3! = 6
;; 5! = 120
(define (fact n)



\end{verbatim}
\end{document}