--- a/cws/cw07.tex Wed Mar 20 21:50:20 2019 +0000
+++ b/cws/cw07.tex Sat Jun 22 08:39:52 2019 +0100
@@ -4,22 +4,24 @@
\begin{document}
-\section*{Replacement Coursework 1 (Roman Numerals)}
+\section*{Scala Part (Roman Numerals)}
-This coursework is worth 10\%. It is about translating roman numerals
-into integers and also about validating roman numerals. The coursework
-is due on 2 February at 5pm. Make sure the files you submit can be
-processed by just calling \texttt{scala <<filename.scala>>}.\bigskip
+This coursework is worth 50\%. It is about translating roman numerals
+into integers. Make sure the files you submit can be
+processed by just calling
+
+\begin{center}
+ \texttt{scala <<filename.scala>>}
+\end{center}%\bigskip
\noindent
\textbf{Important:} Do not use any mutable data structures in your
submission! They are not needed. This menas you cannot use
-\texttt{ListBuffer}s, for example. Do not use \texttt{return} in your
+\texttt{ListBuffer}s, \texttt{Array}s, for example. Do not use \texttt{return} in your
code! It has a different meaning in Scala, than in Java. Do not use
\texttt{var}! This declares a mutable variable. Make sure the
functions you submit are defined on the ``top-level'' of Scala, not
-inside a class or object. Also note that the running time will be
-restricted to a maximum of 360 seconds on my laptop.
+inside a class or object.
\subsection*{Disclaimer}
@@ -30,7 +32,7 @@
you can freely use.\bigskip
-\subsection*{Part 1 (Translation)}
+\subsection*{Tasks}
\noindent
Roman numerals are strings consisting of the letters $I$, $V$, $X$,
@@ -42,7 +44,7 @@
\begin{itemize}
\item[(1)] First write a polymorphic function that recursively
transforms a list of options into an option of a list. For example,
- if you have the lists on the left-hand side, they should be transformed into
+ if you have the lists on the left-hand side below, they should be transformed into
the options on the right-hand side:
\begin{center}
@@ -58,12 +60,12 @@
This means the function should produce \texttt{None} as soon
as a \texttt{None} is inside the list. Otherwise it produces
a list of all \texttt{Some}s. In case the list is empty, it
- produces \texttt{Some} of the empty list. \hfill[1 Mark]
+ produces \texttt{Some} of the empty list. \hfill[15\% Marks]
\item[(2)] Write first a function that converts the characters $I$, $V$,
$X$, $L$, $C$, $D$, and $M$ into an option of a \texttt{RomanDigit}.
- If it is one of the roman digits, it should produce \texttt{Some};
+ If the input is one of the roman digits, the function should produce \texttt{Some};
otherwise \texttt{None}.
Next write a function that converts a string into a
@@ -74,12 +76,12 @@
\texttt{None}. The empty string is just the empty
\texttt{RomanNumeral}, that is the empty list of
\texttt{RomanDigit}'s. You should use the function under Task (1)
- to produce the result. \hfill[2 Marks]
+ to produce the result. \hfill[15\% Marks]
\item[(3)] Write a recursive function \texttt{RomanNumral2Int} that
converts a \texttt{RomanNumeral} into an integer. You can assume the
generated integer will be between 0 and 3999. The argument of the
- function is a list of roman digits. It should look how this list
+ function is a list of roman digits. It should analyse how this list
starts and then calculate what the corresponding integer is for this
``start'' and add it with the integer for the rest of the list. That
means if the argument is of the form shown on the left-hand side, it
@@ -103,27 +105,29 @@
\end{tabular}
\end{center}
- The empty list will be converted to integer $0$.\hfill[1 Mark]
+ The empty list will be converted to integer $0$.\hfill[10\% Mark]
-\item[(4)] Write a function that takes a string and if possible
- converts it into the internal representation. If successful, it then
- calculates the integer (an option of an integer) according to the
+\item[(4)] Write a function that takes a string as input and if possible
+ converts it into the internal representation of Roman Numerals. If successful, it then
+ calculates the corresponding integer (actually an option of an integer) according to the
function in (3). If this is not possible, then return
- \texttt{None}.\hfill[1 Mark]
+ \texttt{None}.\\
+ \mbox{}\hfill[10\% Mark]
-\item[(5)] The file \texttt{roman.txt} contains a list of roman numerals.
- Read in these numerals, convert them into integers and then add them all
- up. The Scala function for reading a file is
-
- \begin{center}
- \texttt{Source.fromFile("filename")("ISO-8859-9")}
- \end{center}
-
- Make sure you process the strings correctly by ignoring whitespaces
- where needed.\\ \mbox{}\hfill[1 Mark]
+%\item[(5)] The file \texttt{roman.txt} contains a list of roman numerals.
+% Read in these numerals, convert them into integers and then add them all
+% up. The Scala function for reading a file is
+%
+% \begin{center}
+% \texttt{Source.fromFile("filename")("ISO-8859-9")}
+% \end{center}
+%
+% Make sure you process the strings correctly by ignoring whitespaces
+% where needed.\\ \mbox{}\hfill[1 Mark]
\end{itemize}
+\end{document}
\subsection*{Part 2 (Validation)}