cws/cw01.tex
changeset 282 ec9773fe1dc0
parent 279 14bf4e478534
child 284 9a04eb6a2291
equal deleted inserted replaced
281:87b9e3e2c1a7 282:ec9773fe1dc0
    13 \mbox{}\hfill\textit{ --- Brian W. Kernighan, in Unix for Beginners (1979)}\medskip\bigskip
    13 \mbox{}\hfill\textit{ --- Brian W. Kernighan, in Unix for Beginners (1979)}\medskip\bigskip
    14 
    14 
    15  
    15  
    16 \noindent
    16 \noindent
    17 This assignment is about Scala and worth 10\%. The preliminary
    17 This assignment is about Scala and worth 10\%. The preliminary
    18 part is due on \cwSIX{} at 16pm, and the core part on \cwSIXa{}
    18 part is due on \cwSIX{} at 4pm, and the core part on \cwSIXa{}
    19 at 16pm. You are asked to implement two programs about list
    19 at 4pm. You are asked to implement two programs about list
    20 processing and recursion. The core part is more advanced and might
    20 processing and recursion. The core part is more advanced and might
    21 include material you have not yet seen in the first lecture.
    21 include material you have not yet seen in the first lecture.
    22 \bigskip
    22 \bigskip
    23  
    23  
    24 \IMPORTANT{}
    24 \IMPORTANT{}
   141   \texttt{Long} as argument type, instead of \texttt{Int}.  You can
   141   \texttt{Long} as argument type, instead of \texttt{Int}.  You can
   142   assume this function will be called with numbers between $1$ and
   142   assume this function will be called with numbers between $1$ and
   143   $1$ Million. \hfill[2 Marks]
   143   $1$ Million. \hfill[2 Marks]
   144 
   144 
   145 \item[(2)] Write a second function that takes an upper bound as
   145 \item[(2)] Write a second function that takes an upper bound as
   146   argument and calculates the steps for all numbers in the range from
   146   an argument and calculates the steps for all numbers in the range from
   147   1 up to this bound (the bound including). It returns the maximum number of
   147   1 up to this bound (the bound including). It returns the maximum number of
   148   steps and the corresponding number that needs that many steps.  More
   148   steps and the corresponding number that needs that many steps.  More
   149   precisely it returns a pair where the first component is the number
   149   precisely it returns a pair where the first component is the number
   150   of steps and the second is the corresponding number. \hfill\mbox{[1
   150   of steps and the second is the corresponding number. \hfill\mbox{[1
   151     Mark]}
   151     Mark]}
   244   lists are for all stock symbols from the portfolio and the outer
   244   lists are for all stock symbols from the portfolio and the outer
   245   list for the years.  For example for Google and Apple in years 2010
   245   list for the years.  For example for Google and Apple in years 2010
   246   (first line), 2011 (second line) and 2012 (third line) you obtain:
   246   (first line), 2011 (second line) and 2012 (third line) you obtain:
   247 
   247 
   248 \begin{verbatim}
   248 \begin{verbatim}
   249   List(List(Some(312.204773), Some(26.782711)), 
   249   List(List(Some(311.349976), Some(20.544939)), 
   250        List(Some(301.0466),   Some(41.244694)), 
   250        List(Some(300.222351), Some(31.638695)), 
   251        List(Some(331.462585), Some(51.464207)))
   251        List(Some(330.555054), Some(39.478039))))
   252 \end{verbatim}\hfill[1 Mark]
   252 \end{verbatim}\hfill[1 Mark]
   253 
   253 
   254 
   254 
   255 %\end{itemize}
   255 %\end{itemize}
   256 
   256