cws/core_cw03.tex
changeset 475 59e005dcf163
parent 471 135bf034ac30
--- a/cws/core_cw03.tex	Thu Nov 02 13:53:37 2023 +0000
+++ b/cws/core_cw03.tex	Thu Nov 02 23:34:53 2023 +0000
@@ -64,11 +64,11 @@
 
 \subsection*{Core Part (3 Marks, files postfix.scala, postfix2.scala)}
 
-The \emph{Shunting Yard Algorithm} has been developed by Edsger Dijkstra,
+The \textit{Shunting Yard Algorithm} has been developed by Edsger Dijkstra,
 an influential computer scientist who developed many well-known
 algorithms. This algorithm transforms the usual infix notation of
 arithmetic expressions into the postfix notation, sometimes also
-called reverse Polish notation.
+called \textit{Reverse Polish Notation}.
 
 Why on Earth do people use the postfix notation? It is much more
 convenient to work with the usual infix notation for arithmetic
@@ -92,9 +92,9 @@
 \end{lstlisting}
 
 \noindent
-where the command \texttt{ldc} loads a constant onto the stack, and \texttt{imul},
-\texttt{isub} and \texttt{iadd} are commands acting on the stack. Clearly this
-is the arithmetic expression in postfix notation.\bigskip
+where the command \texttt{ldc} loads a number onto the stack, and \texttt{imul},
+\texttt{isub} and \texttt{iadd} perform arithmetic operations on the stack. Clearly, this
+is the arithmetic expression from above but in postfix notation.\bigskip
 
 \noindent
 The shunting yard algorithm processes an input token list using an
@@ -123,7 +123,13 @@
   processing the input list.
 \item If the input is empty, then you move all remaining operators
   from the stack to the output list.  
-\end{itemize}  
+\end{itemize}
+
+\noindent
+BTW, the rules above are written ``If\ldots'', but this is because English does not
+include very sophisticated pattern matching. But clearly the rules above should be implemented
+in Scala using pattern matching.
+
 
 \subsubsection*{Tasks (file postfix.scala)}