9 |
9 |
10 \section*{Coursework 7 (Scala)} |
10 \section*{Coursework 7 (Scala)} |
11 |
11 |
12 \mbox{}\hfill\textit{``What one programmer can do in one month,}\\ |
12 \mbox{}\hfill\textit{``What one programmer can do in one month,}\\ |
13 \mbox{}\hfill\textit{two programmers can do in two months.''}\smallskip\\ |
13 \mbox{}\hfill\textit{two programmers can do in two months.''}\smallskip\\ |
14 \mbox{}\hfill\textit{ --- Frederick P.~Brooks (author of The Mythical Man-Month)}\bigskip |
14 \mbox{}\hfill\textit{ --- Frederick P.~Brooks (author of The Mythical Man-Month)}\bigskip\medskip |
15 |
15 |
16 \noindent |
16 \noindent |
17 This coursework is worth 10\%. The basic part is due |
17 This coursework is worth 10\%. The basic part is due |
18 on 22 November at 11pm; the main part is due on 20 |
18 on 22 November at 11pm; the main part is due on 20 |
19 December at 11pm. You are asked to implement Scala programs for |
19 December at 11pm. You are asked to implement Scala programs for |
69 elements in a list that satisfy some condition, \texttt{.toMap} |
69 elements in a list that satisfy some condition, \texttt{.toMap} |
70 transfers a list of pairs into a Map, \texttt{.sum} adds up a list of |
70 transfers a list of pairs into a Map, \texttt{.sum} adds up a list of |
71 integers, \texttt{.max} calculates the maximum of a list.\bigskip |
71 integers, \texttt{.max} calculates the maximum of a list.\bigskip |
72 |
72 |
73 \noindent |
73 \noindent |
74 \textbf{For Part 2 + 3:} use \texttt{.split(",").toList} for splitting |
74 \textbf{For Part 2:} use \texttt{.split(",").toList} for splitting |
75 strings according to commas (similarly $\backslash$\texttt{n}), |
75 strings according to commas (similarly $\backslash$\texttt{n}), |
76 \texttt{.getOrElse(..,..)} allows to querry a Map, but also gives a |
76 \texttt{.getOrElse(..,..)} allows to querry a Map, but also gives a |
77 default value if the Map is not defined, a Map can be `updated' by |
77 default value if the Map is not defined, a Map can be `updated' by |
78 using \texttt{+}, \texttt{.contains} and \texttt{.filter} can test whether |
78 using \texttt{+}, \texttt{.contains} and \texttt{.filter} can test whether |
79 an element is included in a list, and respectively filter out elements in a list, |
79 an element is included in a list, and respectively filter out elements in a list, |
100 \subsection*{Tasks} |
100 \subsection*{Tasks} |
101 |
101 |
102 \begin{itemize} |
102 \begin{itemize} |
103 \item[(1)] Implement a function that `cleans' a string by finding all |
103 \item[(1)] Implement a function that `cleans' a string by finding all |
104 (proper) words in this string. For this use the regular expression |
104 (proper) words in this string. For this use the regular expression |
105 \texttt{$\backslash$w+} for recognising word characters and the |
105 \texttt{\textbackslash{}w+} for recognising words and the library function |
106 library function \texttt{findAllIn}. The function should return a |
106 \texttt{findAllIn}. The function should return a document (a list of |
107 document (a list of |
|
108 strings).\\ |
107 strings).\\ |
109 \mbox{}\hfill [1 Mark] |
108 \mbox{}\hfill [1 Mark] |
110 |
109 |
111 \item[(2)] In order to compute the overlap between two documents, we |
110 \item[(2)] In order to compute the overlap between two documents, we |
112 associate each document with a \texttt{Map}. This Map represents the |
111 associate each document with a \texttt{Map}. This Map represents the |