cws/cw01.tex
changeset 201 018b9c12ee1f
parent 199 54befaf23648
child 202 f7bcb27d1940
--- a/cws/cw01.tex	Fri Nov 09 01:08:43 2018 +0000
+++ b/cws/cw01.tex	Fri Nov 09 07:30:02 2018 +0000
@@ -13,7 +13,7 @@
 
 
 \noindent
-This assignemnt is about Scala and worth 10\%. The first and second
+This assignment is about Scala and worth 10\%. The first and second
 part are due on 16 November at 11pm, and the third part on 21 December
 at 11pm. You are asked to implement two programs about list
 processing and recursion. The third part is more advanced and might
@@ -28,7 +28,7 @@
 
 \DISCLAIMER{}
 
-\subsubsection*{Reference Implementation}
+\subsection*{Reference Implementation}
 
 Like the C++ assignments, the Scala assignments will work like this: you
 push your files to GitHub and receive (after sometimes a long delay) some
@@ -55,6 +55,33 @@
 ...
 \end{lstlisting}%$
 
+\subsection*{Hints}
+
+\noindent
+\textbf{For Part 1:} useful math operators: \texttt{\%} for modulo; useful
+functions: \mbox{\texttt{(1\,to\,10)}} for ranges, \texttt{.toInt},
+\texttt{.toList} for conversions, \texttt{List(...).max} for the
+maximum of a list, \texttt{List(...).indexOf(...)} for the first index of
+a value in a list.\bigskip
+
+\noindent
+\textbf{For Part 2 + 3:} useful string functions: \texttt{.startsWith(...)} for
+checking whether a string has a given prefix, \texttt{\_ ++ \_} for
+concatenating two strings; useful option functions: \texttt{.flatten}
+flattens a list of options such that it filters way all
+\texttt{None}'s, \texttt{Try(...).getOrElse ...} runs some code that
+might raise an exception---if yes, then a default value can be given;
+useful list functions: \texttt{.head} for obtaining the first element
+in a non-empty list, \texttt{.length} for the length of a
+list; \texttt{.filter(...)} for filtering out elements in a list; \texttt{.getLines.toList} for obtaining a list of lines from
+a file; \texttt{.split(",").toList} for splitting strings according to
+a comma.\bigskip
+
+\noindent
+Fortunately Scala supports operator overloading. But make sure you understand the difference between \texttt{100 / 3} and
+\texttt{100.0 / 3}!
+
+\newpage
 \subsection*{Part 1 (3 Marks, file collatz.scala)}
 
 This part is about recursion. You are asked to implement a Scala
@@ -134,12 +161,7 @@
   %% \item[$\bullet$] $1 - 10$ million where $8,400,511$ takes 685 steps
 \end{itemize}
   
-\noindent
-\textbf{Hints:} useful math operators: \texttt{\%} for modulo; useful
-functions: \mbox{\texttt{(1\,to\,10)}} for ranges, \texttt{.toInt},
-\texttt{.toList} for conversions, \texttt{List(...).max} for the
-maximum of a list, \texttt{List(...).indexOf(...)} for the first index of
-a value in a list.
+
 
 
 
@@ -174,15 +196,16 @@
 \end{itemize}
 
 \noindent
-Until Yahoo was bought by Altaba this summer, historical stock market
+Until Yahoo was bought by Altaba last year, historical stock market
 data for such back-of-the-envelope calculations was freely available
-online. Unfortuantely nowadays this kind of data is difficult to
+online. Unfortunately nowadays this kind of data is more difficult to
 obtain, unless you are prepared to pay extortionate prices or be
-severely rate-limited.  Therefore this coursework comes with a number
+severely rate-limited.  Therefore this assignment comes with a number
 of files containing CSV-lists with the historical stock prices for the
 companies in our portfolios. Use these files for the following
 tasks.\bigskip
 
+\newpage
 \noindent
 \textbf{Tasks}
 
@@ -222,7 +245,7 @@
   List(List(Some(311.349976), Some(20.544939)), 
        List(Some(300.222351), Some(31.638695)),
        List(Some(330.555054), Some(39.478039)))
-\end{verbatim}\hfill[1 Marks]
+\end{verbatim}\hfill[1 Mark]
 \end{itemize}
 
 \subsection*{Advanced Part 3 (4 Marks, continue in file drumb.scala)}
@@ -297,17 +320,6 @@
 own calculations: there might be some small rounding errors, which
 when compounded lead to moderately different values.\bigskip
 
-\noindent
-\textbf{Hints:} useful string functions: \texttt{.startsWith(...)} for
-checking whether a string has a given prefix, \texttt{\_ ++ \_} for
-concatenating two strings; useful option functions: \texttt{.flatten}
-flattens a list of options such that it filters way all
-\texttt{None}'s, \texttt{Try(...) getOrElse ...} runs some code that
-might raise an exception---if yes, then a default value can be given;
-useful list functions: \texttt{.head} for obtaining the first element
-in a non-empty list, \texttt{.length} for the length of a
-list.\bigskip
-
 
 \noindent
 \textbf{Moral:} Reflecting on our assumptions, we are over-estimating
@@ -348,7 +360,7 @@
 
 \noindent
 Write another function that can read the file \texttt{population.csv}
-from disk (the file is distributed with the coursework). This
+from disk (the file is distributed with the assignment). This
 function should take a string as argument, the file name, and again
 return a list of strings corresponding to each entry in the
 CSV-list. For \texttt{population.csv}, this list should contain 216