| 66 |      1 | \documentclass[dvipsnames,14pt,t,xelatex]{beamer}
 | 
|  |      2 | \usepackage{../slides}
 | 
|  |      3 | \usepackage{../graphics}
 | 
|  |      4 | \usepackage{../langs}
 | 
|  |      5 | %\usepackage{../data}
 | 
| 67 |      6 | \usepackage[export]{adjustbox}
 | 
| 66 |      7 | 
 | 
|  |      8 | \hfuzz=220pt 
 | 
|  |      9 | 
 | 
|  |     10 | %\setmonofont[Scale=.88]{Consolas}
 | 
|  |     11 | %\newfontfamily{\consolas}{Consolas}
 | 
|  |     12 | 
 | 
|  |     13 | \lstset{language=Scala,
 | 
|  |     14 |         style=mystyle,
 | 
|  |     15 |         numbersep=0pt,
 | 
|  |     16 |         numbers=none,
 | 
|  |     17 |         xleftmargin=0mm}
 | 
|  |     18 | 
 | 
|  |     19 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
|  |     20 | 
 | 
|  |     21 | % beamer stuff 
 | 
| 67 |     22 | \renewcommand{\slidecaption}{PEP (Scala) 03, King's College London}
 | 
| 66 |     23 | 
 | 
|  |     24 | 
 | 
|  |     25 | \begin{document}
 | 
|  |     26 | 
 | 
|  |     27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     28 | \begin{frame}[t]
 | 
|  |     29 | \frametitle{%
 | 
|  |     30 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |     31 |   \\[5mm]
 | 
| 67 |     32 |   \huge PEP Scala (3) 
 | 
| 66 |     33 |   \end{tabular}}
 | 
|  |     34 | 
 | 
|  |     35 |   \normalsize
 | 
|  |     36 |   \begin{center}
 | 
|  |     37 |   \begin{tabular}{ll}
 | 
|  |     38 |   Email:  & christian.urban at kcl.ac.uk\\
 | 
|  |     39 |   Office: & S1.27 (1st floor Strand Building)\\
 | 
|  |     40 |   Slides \& Code: & KEATS
 | 
|  |     41 |   \end{tabular}
 | 
|  |     42 |   \end{center}
 | 
|  |     43 | 
 | 
|  |     44 | 
 | 
|  |     45 | \end{frame}
 | 
|  |     46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |     47 | 
 | 
| 67 |     48 | \begin{frame}[c, fragile]
 | 
|  |     49 | \frametitle{The Joy of Immutability}
 | 
| 66 |     50 | 
 | 
|  |     51 | \begin{itemize}
 | 
| 67 |     52 | \item If you need to manipulate some data in a list say, then you make
 | 
|  |     53 |   a new list with the updated values, rather than revise the original
 | 
|  |     54 |   list. Easy!\medskip
 | 
| 66 |     55 | 
 | 
| 67 |     56 |   {\small
 | 
|  |     57 |   \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |     58 |     val old_list = List(1, 2, 3, 5)
 | 
|  |     59 |     val new_list = 0 :: old_list
 | 
|  |     60 |   \end{lstlisting}}  
 | 
| 66 |     61 |   
 | 
| 67 |     62 | \item You do not have to be defensive about who can access the data
 | 
|  |     63 |   (concurrency, lazyness).
 | 
|  |     64 | \end{itemize}  
 | 
| 66 |     65 | \end{frame}
 | 
|  |     66 | 
 | 
|  |     67 | 
 | 
|  |     68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 67 |     69 | \begin{frame}[t]
 | 
|  |     70 | \frametitle{Email: Hate 'val'}
 | 
|  |     71 | 
 | 
|  |     72 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |     73 | 
 | 
|  |     74 | \begin{center}
 | 
|  |     75 |   \begin{bubble}[10.5cm]
 | 
|  |     76 |   Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
 | 
|  |     77 | 
 | 
|  |     78 |   Hello Mr Urban,\medskip\\
 | 
|  |     79 | 
 | 
|  |     80 |   I just wanted to ask, how are we suppose to work
 | 
|  |     81 |   with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
 | 
|  |     82 |   this rule active at all? I’ve spent 4 hours not thinking on the
 | 
|  |     83 |   coursework, but how to bypass this annoying rule. What’s the whole
 | 
|  |     84 |   point of all these coursework, when we can’t use everything Scala
 | 
|  |     85 |   gives us?!?\medskip\\
 | 
| 66 |     86 | 
 | 
| 67 |     87 |   Regards.\\
 | 
|  |     88 |   \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
 | 
|  |     89 |   \end{bubble}
 | 
|  |     90 | \end{center}
 | 
|  |     91 | 
 | 
|  |     92 | \end{frame}
 | 
|  |     93 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |     94 | 
 | 
|  |     95 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     96 | \begin{frame}[c]
 | 
|  |     97 | 
 | 
|  |     98 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |     99 | 
 | 
|  |    100 | \begin{center}
 | 
|  |    101 |   \begin{bubble}[10.5cm]
 | 
|  |    102 |   Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
 | 
|  |    103 | 
 | 
|  |    104 |   \textcolor{black!70}{
 | 
|  |    105 |     \textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
 | 
|  |    106 |     yada>>}}\bigskip\bigskip\bigskip
 | 
|  |    107 |   
 | 
|  |    108 |   PS: What are you trying to do where you desperately want to use \texttt{var}?
 | 
|  |    109 |   \end{bubble}
 | 
| 66 |    110 | \end{center}
 | 
|  |    111 | 
 | 
|  |    112 | \end{frame}
 | 
|  |    113 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    114 | 
 | 
|  |    115 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 67 |    116 | \begin{frame}[c,fragile]
 | 
|  |    117 | 
 | 
|  |    118 | \begin{textblock}{6}(0.5,0.5)
 | 
|  |    119 | \begin{bubble}[11.5cm]
 | 
|  |    120 |   \small  
 | 
|  |    121 |   Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\
 | 
|  |    122 | 
 | 
|  |    123 |   \textbf{Right now my is\_legal function works fine:}
 | 
|  |    124 |   
 | 
|  |    125 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    126 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
 | 
|  |    127 |    var boolReturn = false
 | 
|  |    128 |    if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
 | 
|  |    129 |    else { var breakLoop = false
 | 
|  |    130 |           if(path == Nil) { boolReturn = true }
 | 
|  |    131 |           else { for(i <- 0 until path.length) {
 | 
|  |    132 |                     if(breakLoop == false) {
 | 
|  |    133 |                       if(path(i) == x) {
 | 
|  |    134 |                         boolReturn = true
 | 
|  |    135 |                         breakLoop = true
 | 
|  |    136 |                       }
 | 
|  |    137 |                       else { boolReturn = false }
 | 
|  |    138 |                     } else breakLoop
 | 
|  |    139 |             }
 | 
|  |    140 |           }
 | 
|  |    141 |           boolReturn
 | 
|  |    142 |    }
 | 
|  |    143 | \end{lstlisting}
 | 
|  |    144 | \end{bubble}
 | 
|  |    145 | \end{textblock}
 | 
|  |    146 | 
 | 
|  |    147 | \begin{textblock}{6}(8.2,11.8)
 | 
|  |    148 | \begin{bubble}[5.5cm]\footnotesize\bf
 | 
|  |    149 | \ldots{}but I can’t make it work with boolReturn being val. What approach would
 | 
|  |    150 | you recommend in this case, and is using var in this case justified?
 | 
|  |    151 | \end{bubble}
 | 
|  |    152 | \end{textblock}
 | 
|  |    153 | 
 | 
|  |    154 | \only<2>{
 | 
|  |    155 | \begin{textblock}{6}(0.3,11.8)
 | 
|  |    156 |   \begin{bubble}[3.1cm]
 | 
|  |    157 |     \textbf{Me:} \includegraphics[scale=0.08, valign=t]{../pics/throwup.jpg}
 | 
|  |    158 |   \end{bubble}
 | 
|  |    159 | \end{textblock}}
 | 
|  |    160 | 
 | 
|  |    161 | \end{frame}
 | 
|  |    162 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    163 | 
 | 
|  |    164 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    165 | \begin{frame}[t,fragile]
 | 
|  |    166 | 
 | 
|  |    167 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    168 | 
 | 
|  |    169 | \begin{textblock}{6}(0.5,2)
 | 
|  |    170 |   \begin{bubble}[11.5cm]
 | 
|  |    171 |   Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
 | 
|  |    172 |   \small
 | 
|  |    173 |   
 | 
|  |    174 |   OK. So you want to make sure that the \texttt{x}-position is not outside the
 | 
|  |    175 |   board....and furthermore you want to make sure that the \texttt{x}-position
 | 
|  |    176 |   is not yet in the path list. How about something like\bigskip
 | 
|  |    177 | 
 | 
|  |    178 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    179 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = 
 | 
|  |    180 |  ...<<some board conditions>>... && !path.contains(x)
 | 
|  |    181 | \end{lstlisting}\bigskip
 | 
|  |    182 |   
 | 
|  |    183 |   \small Does not even contain a \texttt{val}.
 | 
|  |    184 |   \end{bubble}
 | 
|  |    185 | \end{textblock}
 | 
|  |    186 | 
 | 
|  |    187 | \begin{textblock}{6}(7,12)
 | 
|  |    188 | \footnotesize\textcolor{black!50}{(This is all on one line)}
 | 
|  |    189 | \end{textblock}
 | 
|  |    190 | 
 | 
|  |    191 | \end{frame}
 | 
|  |    192 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    193 | 
 | 
|  |    194 | 
 | 
|  |    195 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    196 | \begin{frame}[t,fragile]
 | 
|  |    197 | 
 | 
|  |    198 | \mbox{}\\[-15mm]\mbox{}
 | 
|  |    199 | 
 | 
|  |    200 | \begin{textblock}{6}(1,3)
 | 
|  |    201 |   \begin{bubble}[10.5cm]
 | 
|  |    202 |     Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
 | 
|  |    203 |     
 | 
|  |    204 |     THANK YOU! You made me change my coding perspective. Because of you,
 | 
|  |    205 |     I figured out the next one\ldots
 | 
|  |    206 |   \end{bubble}
 | 
|  |    207 | \end{textblock}
 | 
|  |    208 | 
 | 
|  |    209 | \end{frame}
 | 
|  |    210 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    211 | 
 | 
| 68 |    212 | 
 | 
| 67 |    213 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 66 |    214 | \begin{frame}[c]
 | 
| 68 |    215 |   \frametitle{CW3: Regexes (1 Part)}
 | 
|  |    216 |   
 | 
|  |    217 | \begin{center}
 | 
|  |    218 |   Graphs: $(a^*)^* b$ and strings $\underbrace{\;a\ldots a\;}_{n}$\bigskip
 | 
|  |    219 |   
 | 
|  |    220 | \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}}
 | 
|  |    221 | \raisebox{6mm}{\begin{tikzpicture}
 | 
|  |    222 | \begin{axis}[
 | 
|  |    223 |     xlabel={$n$},
 | 
|  |    224 |     x label style={at={(1.05,0.0)}},
 | 
|  |    225 |     ylabel={time in secs},
 | 
|  |    226 |     enlargelimits=false,
 | 
|  |    227 |     xtick={0,5,...,30},
 | 
|  |    228 |     xmax=33,
 | 
|  |    229 |     ymax=35,
 | 
|  |    230 |     ytick={0,5,...,30},
 | 
|  |    231 |     scaled ticks=false,
 | 
|  |    232 |     axis lines=left,
 | 
|  |    233 |     width=5.5cm,
 | 
|  |    234 |     height=5cm, 
 | 
|  |    235 |     legend entries={Python,  Java},  
 | 
|  |    236 |     legend pos=north west,
 | 
|  |    237 |     legend cell align=left]
 | 
|  |    238 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};  
 | 
|  |    239 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
|  |    240 | \end{axis}
 | 
|  |    241 | \end{tikzpicture}}
 | 
|  |    242 |   &
 | 
| 70 |    243 | \onslide<2>{\begin{tikzpicture}
 | 
| 68 |    244 |   \begin{axis}[
 | 
|  |    245 |     xlabel={$n$},
 | 
|  |    246 |     x label style={at={(1.05,0.0)}},
 | 
|  |    247 |     ylabel={time in secs},
 | 
|  |    248 |     enlargelimits=false,
 | 
|  |    249 |     ymax=35,
 | 
|  |    250 |     ytick={0,5,...,30},
 | 
|  |    251 |     axis lines=left,
 | 
|  |    252 |     %%scaled ticks=false,
 | 
|  |    253 |     width=5.5cm, 
 | 
|  |    254 |     height=5cm]
 | 
|  |    255 | %%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data};    
 | 
|  |    256 | \addplot[red,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
|  |    257 | \end{axis}
 | 
| 70 |    258 | \end{tikzpicture}}
 | 
| 68 |    259 | \end{tabular}
 | 
|  |    260 | \end{center}
 | 
| 66 |    261 | 
 | 
| 68 |    262 | \hfill\small\url{https://vimeo.com/112065252}
 | 
| 66 |    263 | \end{frame}
 | 
| 67 |    264 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    265 | 
 | 
| 68 |    266 | \begin{frame}[c]
 | 
| 67 |    267 | \frametitle{Where to go on from here?}
 | 
|  |    268 | 
 | 
|  |    269 | \begin{itemize}
 | 
|  |    270 | \item Martin Odersky (EPFL)\ldots he is currently throwing out everything
 | 
|  |    271 |   and starts again with the dotty compiler for Scala\medskip
 | 
|  |    272 | 
 | 
|  |    273 | \item Elm (\url{http://elm-lang.org})\ldots web applications with style\medskip   
 | 
|  |    274 | 
 | 
| 68 |    275 | \item Haskell, Ocaml, Standard ML, Scheme, \ldots 
 | 
| 67 |    276 | \end{itemize}  
 | 
|  |    277 | \end{frame}
 | 
|  |    278 | 
 | 
|  |    279 | 
 | 
|  |    280 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    281 | 
 | 
| 66 |    282 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    283 | \begin{frame}[c]
 | 
|  |    284 | \frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
 | 
|  |    285 | 
 | 
| 67 |    286 | \mbox{}\footnotesize
 | 
|  |    287 | Thanks: ``\it{}By the way -  Scala is really getting quite fun
 | 
|  |    288 | when you start to get the hang of it\ldots''
 | 
|  |    289 | 
 | 
| 66 |    290 | \end{frame}
 | 
|  |    291 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 70 |    292 | 
 | 
|  |    293 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    294 | 
 | 
|  |    295 | \begin{frame}[c]
 | 
|  |    296 | \frametitle{Marks for CW6 (Part 1)}
 | 
|  |    297 | 
 | 
|  |    298 | Absolute raw marks, alleged collusions still included:
 | 
|  |    299 | 
 | 
|  |    300 | \begin{itemize}
 | 
|  |    301 | \item 0\%: 18 students
 | 
|  |    302 | \item 1\%: 2
 | 
|  |    303 | \item 2\%: 11
 | 
|  |    304 | \item 3\%: 29
 | 
|  |    305 | \item 4\%: 18
 | 
|  |    306 | \item 5\%: 33
 | 
|  |    307 | \item 6\%: 55
 | 
|  |    308 | \item 7\%: 62 
 | 
|  |    309 | \end{itemize}  
 | 
|  |    310 | \end{frame}
 | 
|  |    311 | 
 | 
|  |    312 | 
 | 
|  |    313 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    314 | 
 | 
| 66 |    315 | \end{document}
 | 
|  |    316 | 
 | 
|  |    317 | 
 | 
|  |    318 | \end{document}
 | 
|  |    319 | 
 | 
|  |    320 | %%% Local Variables:  
 | 
|  |    321 | %%% mode: latex
 | 
|  |    322 | %%% TeX-master: t
 | 
|  |    323 | %%% End: 
 | 
|  |    324 | 
 |