cws/cw02.tex
changeset 306 1877cc717291
parent 301 c3b33c709696
child 316 8b57dd326a91
equal deleted inserted replaced
305:e745f6e1ebf6 306:1877cc717291
     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}
    56 \end{lstlisting}%$
    56 \end{lstlisting}%$
    57 
    57 
    58 \subsection*{Hints}
    58 \subsection*{Hints}
    59 
    59 
    60 \noindent
    60 \noindent
    61 \textbf{For Part 1:} useful operations involving regular
    61 \textbf{For Preliminary Part:} useful operations involving regular
    62 expressions:
    62 expressions:
    63 \[\texttt{reg.findAllIn(s).toList}\]
    63 \[\texttt{reg.findAllIn(s).toList}\]
    64 \noindent finds all
    64 \noindent finds all
    65 substrings in \texttt{s} according to a regular regular expression
    65 substrings in \texttt{s} according to a regular regular expression
    66 \texttt{reg}; useful list operations: \texttt{.distinct}
    66 \texttt{reg}; useful list operations: \texttt{.distinct}
    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,