
diff -r 85f2f75abeeb -r 2d57b0d43a0f cws/cw03.tex
--- a/cws/cw03.tex	Wed Nov 30 10:07:05 2016 +0000
+++ b/cws/cw03.tex	Thu Dec 01 17:08:02 2016 +0000
@@ -6,12 +6,12 @@
 
 \section*{Coursework 8 (Scala, Regular Expressions}
 
-This coursework is worth 10\%. It is about regular expressions and
-pattern matching. The first part is due on 30 November at 11pm; the
-second, more advanced part, is due on 7 December at 11pm. You are
-asked to implement a regular expression matcher. Make sure the files
-you submit can be processed by just calling \texttt{scala
-  <<filename.scala>>}.\bigskip
+This coursework is worth 10\%. It is about regular expressions,
+pattern matching and polymorphism. The first part is due on 30
+November at 11pm; the second, more advanced part, is due on 7 December
+at 11pm. You are asked to implement a regular expression matcher. Make
+sure the files you submit can be processed by just calling
+\texttt{scala <<filename.scala>>}.\bigskip
 
 \noindent
 \textbf{Important:} Do not use any mutable data structures in your
@@ -65,7 +65,7 @@
 \item[$\bullet$] \url{http://davidvgalbraith.com/how-i-fixed-atom/}  
 \end{itemize}}
 
-\subsection*{Tasks (file re.scala)}
+\subsubsection*{Tasks (file re.scala)}
 
 \begin{itemize}
 \item[(1a)] Implement a function, called \textit{nullable}, by recursion over
@@ -159,8 +159,17 @@
   For example the regular expression
   \[(r_1 + \ZERO) \cdot \ONE + ((\ONE + r_2) + r_3) \cdot (r_4 \cdot \ZERO)\]
 
-  simplifies to just $r_1$. 
-  \hfill[1 Mark]
+  simplifies to just $r_1$. \textbf{Hints:} Regular expressions can be
+  seen as trees and there are several methods for traversing
+  trees. One of them corresponds to the inside-out traversal. Also
+  remember numerical expressions from school: there you had exprssions
+  like $u + \ldots + (1 \cdot x) * \ldots (z + (y \cdot 0)) \ldots$
+  and simplification rules that looked very similar to rules
+  above. You would simplify such numerical expressions by replacing
+  for example the $y \cdot 0$ by $0$, or $1\cdot x$ by $x$, and then
+  look if more rules are applicable. If you organise this
+  simplification in an inside-out fashion, it is always clear which
+  rule should applied next.\\\mbox{}\hfill[1 Mark]
 
 \item[(1d)] Implement two functions: The first, called \textit{ders},
   takes a list of characters and a regular expression as arguments, and
@@ -215,7 +224,7 @@
 give you another method and datapoints for testing the \textit{der}
 and \textit{simp} functions from Part~1.
 
-\subsection*{Tasks (file re2.scala)}
+\subsubsection*{Tasks (file re2.scala)}
 
 \begin{itemize}
 \item[(2a)] Write a \textbf{polymorphic} function, called
@@ -240,7 +249,7 @@
 
   Make sure you write a \textbf{tail-recursive} version of
   \textit{iterT}.  If you add the annotation \texttt{@tailrec} (see
-  below) you should not get an error message.
+  below) your code should not produce an error message.
 
   \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]  
   import scala.annotation.tailrec
@@ -253,7 +262,8 @@
   integers $0 \le n$. Given the type variable \texttt{A}, the type of
   $f$ is \texttt{A => A} and the type of $x$ is \texttt{A}. This means
   \textit{iterT} can be used, for example, for functions from integers
-  to integers, or strings to strings.  \\ \mbox{}\hfill[2 Marks]
+  to integers, or strings to strings, or regular expressions to
+  regular expressions.  \\ \mbox{}\hfill[2 Marks]
 
 \item[(2b)] Implement a function, called \textit{size}, by recursion
   over regular expressions. If a regular expression is seen as a tree,
@@ -273,7 +283,7 @@
 
 You can use \textit{size} and \textit{iterT} in order to test how much
 the 'evil' regular expression $(a^*)^* \cdot b$ grows when taking
-successive derivatives according the letter $a$ and compare it to
+successive derivatives according the letter $a$ and then compare it to
 taking the derivative, but simlifying the derivative after each step.
 For example, the calls
 
@@ -283,7 +293,8 @@
   \end{lstlisting}
 
   produce without simplification a regular expression of size of
-  7340068 for the derivative after 20 iterations, while the latter is
+  7340068 after 20 iterations, while the one with
+  simplification gives
   just 8.\\ \mbox{}\hfill[1 Mark]
   
 




