\documentclass{article}
\usepackage{../style}
\usepackage{../langs}
\usepackage{../graphics}

\begin{document}

\section*{Homework 8}

\HEADER

\begin{enumerate}
\item Write a program in the WHILE-language that calculates
      the factorial function.

\item What optimisations could a compiler perform when
      compiling a WHILE-program?

\item What is the main difference between the Java assembler
      (as processed by Jasmin) and Java Byte Code?

\item Consider the following Scala snippet. Are the two functions
\texttt{is\_even} and \texttt{is\_odd} tail-recursive?     

\begin{lstlisting}[numbers=none]
def is_even(n: Int) : Boolean = {
    if (n == 0) true else is_odd(n - 1)
}

def is_odd(n: Int) : Boolean = {
    if (n == 0) false 
    else if (n == 1) true else is_even(n - 1)
}
\end{lstlisting}
      
Do they cause stack-overflows when compiled to the JVM (for example by Scala)?


\item Explain what is meant by the terms lazy evaluation and eager
  evaluation.

\item \POSTSCRIPT    
\end{enumerate}

\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
