5 \usepackage{../langs} |
5 \usepackage{../langs} |
6 |
6 |
7 \begin{document} |
7 \begin{document} |
8 |
8 |
9 |
9 |
10 \section*{Coursework 7 (Scala)} |
10 \section*{Part 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\medskip |
14 \mbox{}\hfill\textit{ --- Frederick P.~Brooks (author of The Mythical Man-Month)}\bigskip\medskip |
15 |
15 |
29 \DISCLAIMER{} |
29 \DISCLAIMER{} |
30 |
30 |
31 |
31 |
32 \subsection*{Reference Implementation} |
32 \subsection*{Reference Implementation} |
33 |
33 |
34 Like the C++ assignments, the Scala assignments will work like this: you |
34 Like the C++ part, the Scala part works like this: you |
35 push your files to GitHub and receive (after sometimes a long delay) some |
35 push your files to GitHub and receive (after sometimes a long delay) some |
36 automated feedback. In the end we take a snapshot of the submitted files and |
36 automated feedback. In the end we will take a snapshot of the submitted files and |
37 apply an automated marking script to them.\medskip |
37 apply an automated marking script to them.\medskip |
38 |
38 |
39 \noindent |
39 \noindent |
40 In addition, the Scala assignments come with a reference |
40 In addition, the Scala part comes with reference |
41 implementation in form of a \texttt{jar}-file. This allows you to run |
41 implementations in form of \texttt{jar}-files. This allows you to run |
42 any test cases on your own computer. For example you can call Scala on |
42 any test cases on your own computer. For example you can call Scala on |
43 the command line with the option \texttt{-cp docdiff.jar} and then |
43 the command line with the option \texttt{-cp docdiff.jar} and then |
44 query any function from the template file. Say you want to find out |
44 query any function from the template file. Say you want to find out |
45 what the function \texttt{occurrences} produces: for this you just need |
45 what the function \texttt{occurrences} produces: for this you just need |
46 to prefix it with the object name \texttt{CW7a} (and \texttt{CW7b} |
46 to prefix it with the object name \texttt{CW7a} (and \texttt{CW7b} |
68 elements in a list that satisfy some condition, \texttt{.toMap} |
68 elements in a list that satisfy some condition, \texttt{.toMap} |
69 transfers a list of pairs into a Map, \texttt{.sum} adds up a list of |
69 transfers a list of pairs into a Map, \texttt{.sum} adds up a list of |
70 integers, \texttt{.max} calculates the maximum of a list.\bigskip |
70 integers, \texttt{.max} calculates the maximum of a list.\bigskip |
71 |
71 |
72 \noindent |
72 \noindent |
73 \textbf{For Part 2:} use \texttt{.split(",").toList} for splitting |
73 \textbf{For Core Part:} use \texttt{.split(",").toList} for splitting |
74 strings according to commas (similarly $\backslash$\texttt{n}), |
74 strings according to commas (similarly $\backslash$\texttt{n}), |
75 \texttt{.getOrElse(..,..)} allows to query a Map, but also gives a |
75 \texttt{.getOrElse(..,..)} allows to query a Map, but also gives a |
76 default value if the Map is not defined, a Map can be `updated' by |
76 default value if the Map is not defined, a Map can be `updated' by |
77 using \texttt{+}, \texttt{.contains} and \texttt{.filter} can test whether |
77 using \texttt{+}, \texttt{.contains} and \texttt{.filter} can test whether |
78 an element is included in a list, and respectively filter out elements in a list, |
78 an element is included in a list, and respectively filter out elements in a list, |