cws/cw04.tex
changeset 110 62389faa66e4
parent 109 293ea84d82ca
child 111 cd6b9fe4bce5
equal deleted inserted replaced
109:293ea84d82ca 110:62389faa66e4
    11 is due on 2 February at 5pm.  Make sure the files you submit can be
    11 is due on 2 February at 5pm.  Make sure the files you submit can be
    12 processed by just calling \texttt{scala <<filename.scala>>}.\bigskip
    12 processed by just calling \texttt{scala <<filename.scala>>}.\bigskip
    13 
    13 
    14 \noindent
    14 \noindent
    15 \textbf{Important:} Do not use any mutable data structures in your
    15 \textbf{Important:} Do not use any mutable data structures in your
    16 submission! They are not needed. This excludes the use of
    16 submission! They are not needed. This menas you cannot use 
    17 \texttt{ListBuffer}s, for example. Do not use \texttt{return} in your
    17 \texttt{ListBuffer}s, for example. Do not use \texttt{return} in your
    18 code! It has a different meaning in Scala, than in Java.  Do not use
    18 code! It has a different meaning in Scala, than in Java.  Do not use
    19 \texttt{var}! This declares a mutable variable.  Make sure the
    19 \texttt{var}! This declares a mutable variable.  Make sure the
    20 functions you submit are defined on the ``top-level'' of Scala, not
    20 functions you submit are defined on the ``top-level'' of Scala, not
    21 inside a class or object. Also note that the running time will be
    21 inside a class or object. Also note that the running time will be
    22 restricted to a maximum of 360 seconds.
    22 restricted to a maximum of 360 seconds on my laptop.
    23 
    23 
    24 
    24 
    25 \subsection*{Disclaimer}
    25 \subsection*{Disclaimer}
    26 
    26 
    27 It should be understood that the work you submit represents your own
    27 It should be understood that the work you submit represents your own
    41 
    41 
    42 \begin{itemize}
    42 \begin{itemize}
    43 \item[(1)] First write a polymorphic function that recursively
    43 \item[(1)] First write a polymorphic function that recursively
    44   transforms a list of options into an option of a list. For example,
    44   transforms a list of options into an option of a list. For example,
    45   if you have the lists on the left-hand side, they should be transformed into
    45   if you have the lists on the left-hand side, they should be transformed into
    46   the option on the right-hand side:
    46   the options on the right-hand side:
    47 
    47 
    48   \begin{center}
    48   \begin{center}
    49   \begin{tabular}{lcl}  
    49   \begin{tabular}{lcl}  
    50     \texttt{List(Some(1), Some(2), Some(3))} & $\Rightarrow$ &
    50     \texttt{List(Some(1), Some(2), Some(3))} & $\Rightarrow$ &
    51     \texttt{Some(List(1, 2, 3))} \\
    51     \texttt{Some(List(1, 2, 3))} \\