| 308 |      1 | % !TEX program = xelatex
 | 
| 352 |      2 | \documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
 | 
| 439 |      3 | \usepackage{../styles/slides}
 | 
|  |      4 | \usepackage{../styles/mygraphs}
 | 
|  |      5 | \usepackage{../styles/langs}
 | 
| 22 |      6 | %\usepackage{../data}
 | 
| 439 |      7 | \usetikzlibrary{shapes} 
 | 
| 22 |      8 | 
 | 
| 439 |      9 | \hfuzz=220pt  
 | 
| 22 |     10 | 
 | 
|  |     11 | %\setmonofont[Scale=.88]{Consolas}
 | 
|  |     12 | %\newfontfamily{\consolas}{Consolas}
 | 
|  |     13 | 
 | 
|  |     14 | \lstset{language=Scala,
 | 
|  |     15 |         style=mystyle,
 | 
|  |     16 |         numbersep=0pt,
 | 
|  |     17 |         numbers=none,
 | 
|  |     18 |         xleftmargin=0mm}
 | 
|  |     19 | 
 | 
| 353 |     20 | 
 | 
|  |     21 | \colorlet{punct}{red!60!black}
 | 
|  |     22 | \definecolor{background}{HTML}{EEEEEE}
 | 
|  |     23 | \definecolor{delim}{RGB}{20,105,176}
 | 
|  |     24 | \colorlet{numb}{magenta!60!black}
 | 
|  |     25 | 
 | 
|  |     26 | \lstdefinelanguage{json}{
 | 
|  |     27 |     basicstyle=\normalfont\ttfamily,
 | 
|  |     28 |     numbers=left,
 | 
|  |     29 |     numberstyle=\scriptsize,
 | 
|  |     30 |     stepnumber=1,
 | 
|  |     31 |     %numbersep=8pt,
 | 
|  |     32 |     showstringspaces=false,
 | 
|  |     33 |     breaklines=true,
 | 
|  |     34 |     %frame=lines,
 | 
|  |     35 |     %backgroundcolor=\color{background},
 | 
|  |     36 |     literate=
 | 
|  |     37 |      *{0}{{{\color{numb}0}}}{1}
 | 
|  |     38 |       {1}{{{\color{numb}1}}}{1}
 | 
|  |     39 |       {2}{{{\color{numb}2}}}{1}
 | 
|  |     40 |       {3}{{{\color{numb}3}}}{1}
 | 
|  |     41 |       {4}{{{\color{numb}4}}}{1}
 | 
|  |     42 |       {5}{{{\color{numb}5}}}{1}
 | 
|  |     43 |       {6}{{{\color{numb}6}}}{1}
 | 
|  |     44 |       {7}{{{\color{numb}7}}}{1}
 | 
|  |     45 |       {8}{{{\color{numb}8}}}{1}
 | 
|  |     46 |       {9}{{{\color{numb}9}}}{1}
 | 
|  |     47 |       {:}{{{\color{punct}{:}}}}{1}
 | 
|  |     48 |       {,}{{{\color{punct}{,}}}}{1}
 | 
|  |     49 |       {\{}{{{\color{delim}{\{}}}}{1}
 | 
|  |     50 |       {\}}{{{\color{delim}{\}}}}}{1}
 | 
|  |     51 |       {[}{{{\color{delim}{[}}}}{1}
 | 
|  |     52 |       {]}{{{\color{delim}{]}}}}{1},
 | 
|  |     53 | }     
 | 
|  |     54 | 
 | 
| 309 |     55 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}    
 | 
|  |     56 | 
 | 
|  |     57 | \newcommand{\RIGHTarrow}[3]{%
 | 
|  |     58 | \begin{textblock}{0}(#2,#3)%
 | 
|  |     59 | \onslide<#1>{%
 | 
|  |     60 | \begin{tikzpicture}%
 | 
|  |     61 | \node at (0,0) [single arrow, shape border rotate=0, fill=red,text=red]{a};%
 | 
|  |     62 | \end{tikzpicture}}%
 | 
|  |     63 | \end{textblock}}
 | 
|  |     64 | \newcommand{\LEFTarrow}[3]{%
 | 
|  |     65 | \begin{textblock}{0}(#2,#3)%
 | 
|  |     66 | \onslide<#1>{%
 | 
|  |     67 | \begin{tikzpicture}%
 | 
|  |     68 | \node at (0,0) [single arrow, shape border rotate=180, fill=red,text=red]{a};%
 | 
|  |     69 | \end{tikzpicture}}%
 | 
|  |     70 | \end{textblock}}
 | 
|  |     71 | \newcommand{\DOWNarrow}[3]{%
 | 
|  |     72 | \begin{textblock}{0}(#2,#3)%
 | 
|  |     73 | \onslide<#1>{%
 | 
|  |     74 | \begin{tikzpicture}%
 | 
|  |     75 | \node at (0,0) [single arrow, shape border rotate=270, fill=red,text=red]{a};%
 | 
|  |     76 | \end{tikzpicture}}%
 | 
|  |     77 | \end{textblock}}
 | 
| 22 |     78 | 
 | 
|  |     79 | % beamer stuff 
 | 
| 195 |     80 | \renewcommand{\slidecaption}{PEP (Scala) \liningnums{01}, King's College London}
 | 
| 22 |     81 | 
 | 
| 334 |     82 | % https://insights.stackoverflow.com/survey/2019#technology-most-loved-dreaded-and-wanted
 | 
|  |     83 | 
 | 
|  |     84 | % processors in the future / Ahmdahl law
 | 
|  |     85 | % https://www.youtube.com/watch?v=_9mzmvhwMqw
 | 
|  |     86 | 
 | 
| 352 |     87 | \setbeamertemplate{itemize items}{$\bullet$}
 | 
|  |     88 | \setbeamertemplate{itemize subitem}{$\bullet$}
 | 
|  |     89 | \setbeamertemplate{itemize subsubitem}{$\bullet$}
 | 
|  |     90 | 
 | 
|  |     91 | \usepackage{tcolorbox}
 | 
|  |     92 | \newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
 | 
|  |     93 | \newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
 | 
|  |     94 | \newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
 | 
| 22 |     95 | 
 | 
|  |     96 | \begin{document}
 | 
|  |     97 | 
 | 
|  |     98 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     99 | \begin{frame}[t]
 | 
|  |    100 | \frametitle{%
 | 
|  |    101 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |    102 |   \\[5mm]
 | 
| 199 |    103 |   \hspace{7mm}\huge PEP Scala (\liningnums{1}) 
 | 
| 22 |    104 |   \end{tabular}}
 | 
|  |    105 | 
 | 
|  |    106 |   \normalsize
 | 
|  |    107 |   \begin{center}
 | 
|  |    108 |   \begin{tabular}{ll}
 | 
| 137 |    109 |     Email:  & christian.urban at kcl.ac.uk\\
 | 
| 353 |    110 |     %Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
 | 
| 309 |    111 |     Slides \& Code: & KEATS\bigskip\\
 | 
| 439 |    112 | 
 | 
|  |    113 |     Office Hour: &  Fridays 11:00 -- 12:00\\
 | 
|  |    114 |     Location: & N7.07 (North Wing, Bush House)\bigskip\\
 | 
|  |    115 | 
 | 
|  |    116 |     Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\  \\
 | 
| 353 |    117 |     %Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\ 
 | 
| 22 |    118 |   \end{tabular}
 | 
|  |    119 |   \end{center}
 | 
|  |    120 | 
 | 
| 199 |    121 |   %\tiny
 | 
|  |    122 |   %developed since 2004 bv Martin Odersky
 | 
|  |    123 |   %picture about assignments
 | 
|  |    124 | 
 | 
|  |    125 | \begin{textblock}{6}(0.5,0.5)
 | 
|  |    126 | \includegraphics[scale=0.035]{../pics/assign.jpg}\\[-1mm]
 | 
|  |    127 | \end{textblock}
 | 
| 22 |    128 | 
 | 
|  |    129 | \end{frame}
 | 
|  |    130 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    131 | 
 | 
|  |    132 | 
 | 
|  |    133 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    134 | \begin{frame}[c]
 | 
|  |    135 | \frametitle{Why Scala?}
 | 
|  |    136 | 
 | 
| 352 |    137 | \begin{textblock}{6}(3,3)
 | 
| 22 |    138 | \begin{tabular}{l}
 | 
| 439 |    139 | %%\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
 | 
| 22 |    140 | \includegraphics[scale=0.30]{../pics/linked.png}\\
 | 
| 141 |    141 | \includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
 | 
| 22 |    142 | \mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
 | 
|  |    143 | \includegraphics[scale=0.30]{../pics/suisse.png}\\
 | 
| 23 |    144 | {\large\bf ...}
 | 
|  |    145 | \end{tabular}
 | 
|  |    146 | \end{textblock}
 | 
|  |    147 | 
 | 
| 352 |    148 | \begin{textblock}{6}(9,3)
 | 
| 23 |    149 | \begin{tabular}{l}
 | 
| 22 |    150 | \includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
 | 
|  |    151 | \includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
 | 
|  |    152 | \includegraphics[scale=0.30]{../pics/foursquare.png}\\
 | 
|  |    153 | \includegraphics[scale=0.30]{../pics/hsbc.png}\\
 | 
|  |    154 | {\large\bf ...}
 | 
|  |    155 | \end{tabular}
 | 
|  |    156 | \end{textblock}
 | 
|  |    157 | 
 | 
| 199 |    158 | 
 | 
| 352 |    159 | \begin{textblock}{12}(2,11)
 | 
|  |    160 |   \footnotesize
 | 
|  |    161 |   \begin{mybox3}{A former student working now at Quantexa:}\it
 | 
|  |    162 |     ``I am a former student. I graduated last year. I got my dream job
 | 
|  |    163 |     as a backend Scala developer. Most of the Scala I know is from PEP
 | 
|  |    164 |     2018/19. My interviewers said they expect code of a lesser quality
 | 
|  |    165 |     even from people with one year of experience.''
 | 
|  |    166 | \end{mybox3}
 | 
|  |    167 | \end{textblock}  
 | 
| 199 |    168 | 
 | 
| 22 |    169 | \end{frame}
 | 
|  |    170 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    171 | 
 | 
| 352 |    172 | %\begin{textblock}{6}(2,12)
 | 
|  |    173 | %\begin{bubble}[9.4cm]
 | 
|  |    174 | %  \small
 | 
|  |    175 | %  developed since 2004 by Martin Odersky
 | 
|  |    176 | %  (he was behind Generic Java which was included in Java 5
 | 
|  |    177 | %  \ldots I am using Scala since maybe 2008?)
 | 
|  |    178 | %\end{bubble}
 | 
|  |    179 | %\end{textblock}
 | 
| 23 |    180 | 
 | 
|  |    181 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    182 | \begin{frame}[c]
 | 
|  |    183 | \frametitle{Why Scala?}
 | 
|  |    184 | 
 | 
|  |    185 | \begin{itemize}
 | 
| 34 |    186 | \item compiles to the JVM\\
 | 
|  |    187 |   \textcolor{gray}{(also JavaScript, native X86 in the works)}\medskip
 | 
| 32 |    188 | \item integrates seamlessly with Java\medskip
 | 
| 352 |    189 | \item combines \underline{\bf functional} and {\bf object-oriented} programming\medskip
 | 
|  |    190 | 
 | 
|  |    191 | \item no pointers, no null
 | 
|  |    192 | %\item it is a bit on the ``theory'' / ``mathematical'' side\\
 | 
|  |    193 | %  \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
 | 
| 34 |    194 |   
 | 
| 33 |    195 | \item often one can write very concise and elegant code
 | 
|  |    196 | \end{itemize}\bigskip\medskip  
 | 
|  |    197 | 
 | 
| 308 |    198 | %\small
 | 
|  |    199 | %alternatives:\\
 | 
|  |    200 | %Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots
 | 
| 23 |    201 | 
 | 
|  |    202 | \end{frame}
 | 
| 22 |    203 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 23 |    204 | 
 | 
|  |    205 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 308 |    206 | \begin{frame}[t]
 | 
| 32 |    207 | \frametitle{Java vs Scala}
 | 
|  |    208 | 
 | 
| 308 |    209 | {\lstset{language=java,numbers=right}\fontsize{12}{12}\selectfont
 | 
| 32 |    210 | \texttt{\lstinputlisting{Point.java}}}
 | 
|  |    211 | 
 | 
| 308 |    212 | \rule{11cm}{0.3mm}\\[-3mm]
 | 
| 33 |    213 | 
 | 
| 32 |    214 | {\lstset{language=scala}\fontsize{12}{12}\selectfont
 | 
|  |    215 | \texttt{\lstinputlisting{Point.scala}}}
 | 
|  |    216 | 
 | 
|  |    217 | \begin{textblock}{6}(13,3)
 | 
|  |    218 | \textbf{\large Java}
 | 
| 33 |    219 | \end{textblock}
 | 
|  |    220 | 
 | 
| 308 |    221 | \begin{textblock}{6}(13,14.3)
 | 
| 32 |    222 | \textbf{\large Scala}
 | 
|  |    223 | \end{textblock}  
 | 
|  |    224 | 
 | 
|  |    225 | \end{frame}
 | 
|  |    226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    227 | 
 | 
| 174 |    228 | 
 | 
|  |    229 | 
 | 
|  |    230 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    231 | \begin{frame}[c]
 | 
| 137 |    232 | \frametitle{First Steps: Scala Tools}
 | 
| 32 |    233 | 
 | 
| 33 |    234 | \begin{itemize}
 | 
| 308 |    235 | \item contains a REPL  
 | 
| 200 |    236 | \item I use VS Code and a Scala extension (M'place)
 | 
| 199 |    237 | \begin{center}  
 | 
|  |    238 | \includegraphics[scale=0.10]{../pics/vscode.png}\\[-10mm]\mbox{}
 | 
|  |    239 | \end{center}\bigskip
 | 
|  |    240 |   
 | 
| 33 |    241 | \item there is a plugin for Eclipse (called Scala IDE)\medskip
 | 
| 137 |    242 | \item there is also a plugin for IntelliJ\medskip
 | 
| 33 |    243 | \end{itemize}  
 | 
|  |    244 | 
 | 
|  |    245 | \end{frame}
 | 
| 137 |    246 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    247 | 
 | 
|  |    248 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 353 |    249 | \begin{frame}[c, fragile]
 | 
|  |    250 | 
 | 
|  |    251 | \small  
 | 
|  |    252 | My personal keboard shortcut for VS Code\\
 | 
|  |    253 | (in keybindings.json)\bigskip
 | 
|  |    254 | 
 | 
| 360 |    255 | \footnotesize
 | 
|  |    256 | \begin{lstlisting}[language=json,numbers=none,xrightmargin=-4cm]
 | 
| 353 |    257 | [
 | 
|  |    258 |     {
 | 
|  |    259 |         "key": "ctrl+enter",
 | 
|  |    260 |         "command": "workbench.action.terminal.runSelectedText",
 | 
|  |    261 |         "when": "editorTextFocus && editorHasSelection"
 | 
|  |    262 |       }
 | 
|  |    263 | ]      
 | 
|  |    264 | \end{lstlisting}
 | 
|  |    265 | 
 | 
|  |    266 |   
 | 
|  |    267 | \end{frame}
 | 
|  |    268 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    269 | 
 | 
|  |    270 | 
 | 
|  |    271 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 309 |    272 | \begin{frame}[t]
 | 
|  |    273 | \frametitle{Why Scala?}
 | 
|  |    274 | 
 | 
|  |    275 | \onslide<2->{%
 | 
|  |    276 | \begin{center} 
 | 
|  |    277 | {\large\bf{}Money?}\bigskip\\  
 | 
|  |    278 | \begin{tabular}{@{}c@{}c@{}}
 | 
|  |    279 | \includegraphics[scale=0.2]{../pics/salary1.png} &
 | 
|  |    280 | \includegraphics[scale=0.2]{../pics/salary2.png}\\
 | 
|  |    281 | \multicolumn{2}{r@{}}{\footnotesize$^*$ source: Stackoverflow Developer Survey, 2019}
 | 
|  |    282 | \end{tabular}  
 | 
|  |    283 | \end{center}
 | 
| 353 |    284 | \RIGHTarrow{2}{2.0}{6.3}
 | 
| 314 |    285 | \DOWNarrow{2}{10.1}{4.4}
 | 
| 309 |    286 | }
 | 
|  |    287 | 
 | 
|  |    288 | 
 | 
|  |    289 | \small
 | 
|  |    290 | Elm, Rust, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots 
 | 
|  |    291 | 
 | 
|  |    292 | \only<3>{
 | 
|  |    293 | \begin{textblock}{6}(3.3,6.2)
 | 
|  |    294 | \begin{bubble}[6.5cm]
 | 
|  |    295 | \bf\huge\textcolor{RoyalBlue}{Functional Programming!}
 | 
|  |    296 | \end{bubble}
 | 
|  |    297 | \end{textblock}}
 | 
|  |    298 | 
 | 
|  |    299 | \end{frame}
 | 
|  |    300 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    301 | 
 | 
|  |    302 | 
 | 
|  |    303 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 137 |    304 | \begin{frame}[c]
 | 
| 309 |    305 |   \frametitle{\begin{tabular}{c}\\[2mm]
 | 
|  |    306 |   Why Functional\\[-2mm] Programming?\end{tabular}
 | 
| 137 |    307 | }
 | 
|  |    308 | 
 | 
|  |    309 |   %
 | 
|  |    310 |   \mbox{}\\[3.5cm]
 | 
|  |    311 |   \small
 | 
| 309 |    312 | Elm, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots 
 | 
| 137 |    313 | 
 | 
| 309 |    314 | \only<2>{
 | 
|  |    315 | \begin{textblock}{6}(1.3,6.2)
 | 
| 137 |    316 | \begin{bubble}[10cm]
 | 
|  |    317 | \normalsize``If you want to see which features will be in mainstream programming
 | 
|  |    318 |   languages tomorrow, then take a look at functional programming
 | 
|  |    319 |   languages today.''\medskip\small\\
 | 
|  |    320 |   \hfill{}---Simon Peyton Jones (works at Microsoft)\\
 | 
|  |    321 |   \hfill{}main developer of the Glasgow Haskell Compiler
 | 
|  |    322 | \end{bubble}
 | 
|  |    323 | \end{textblock}}
 | 
|  |    324 | 
 | 
| 309 |    325 | \only<3>{
 | 
| 200 |    326 | \begin{textblock}{6}(5,5.8)
 | 
|  |    327 | \hspace{2mm}\includegraphics[scale=0.06]{../pics/assign.jpg}\\[-1mm]
 | 
| 309 |    328 | \Large\alert{\hspace{5mm}\textbf{Immutability}}
 | 
| 200 |    329 | \end{textblock}}
 | 
|  |    330 | 
 | 
|  |    331 | 
 | 
| 137 |    332 | \end{frame}
 | 
|  |    333 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    334 | 
 | 
| 200 |    335 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 309 |    336 | \begin{frame}[c]
 | 
|  |    337 | 
 | 
|  |    338 | \begin{center}  
 | 
|  |    339 | \includegraphics[scale=0.4]{../pics/pure.png}
 | 
|  |    340 | \end{center}
 | 
|  |    341 | 
 | 
|  |    342 | \begin{textblock}{6}(9,14)
 | 
|  |    343 | \tiny$^*$ from ``What pure functional programming is all about?''
 | 
|  |    344 | \end{textblock}
 | 
|  |    345 | \end{frame}
 | 
|  |    346 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    347 |   
 | 
|  |    348 | 
 | 
|  |    349 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 200 |    350 | \begin{frame}[c, fragile]
 | 
|  |    351 | 
 | 
|  |    352 | {\Large Why bother? or\smallskip\\\hfill What is wrong with this?}\bigskip\bigskip
 | 
|  |    353 | 
 | 
|  |    354 |   
 | 
|  |    355 | \begin{lstlisting}[language=C,numbers=none]
 | 
|  |    356 | for (int i = 10; i < 20; i++) {
 | 
|  |    357 |     
 | 
|  |    358 |   //...Do something interesting
 | 
|  |    359 |   //   with i...
 | 
|  |    360 | 
 | 
|  |    361 | }
 | 
|  |    362 | \end{lstlisting}
 | 
|  |    363 | 
 | 
|  |    364 |   
 | 
|  |    365 | \end{frame}
 | 
|  |    366 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    367 | 
 | 
|  |    368 | 
 | 
|  |    369 | 
 | 
| 137 |    370 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    371 | \begin{frame}[c]
 | 
|  |    372 | \mbox{}\\[-21mm]\mbox{}  
 | 
|  |    373 | 
 | 
|  |    374 | \begin{center}
 | 
|  |    375 |   \begin{tikzpicture}[scale=1,
 | 
|  |    376 |                       node/.style={
 | 
|  |    377 |                       rectangle,rounded corners=3mm,
 | 
|  |    378 |                       very thick,draw=black!50,
 | 
|  |    379 |                       minimum height=18mm, minimum width=20mm,
 | 
|  |    380 |                       top color=white,bottom color=black!20}]
 | 
|  |    381 | 
 | 
|  |    382 |   \onslide<1-10>{                
 | 
|  |    383 |   \node (A) at (0,0) [node]
 | 
|  |    384 |      {\mbox{\includegraphics[scale=0.15]{../pics/cplus2.jpg}}};
 | 
|  |    385 |   \node [above right] at (A.north west) {1986};}
 | 
|  |    386 | 
 | 
|  |    387 |   \onslide<2->{
 | 
|  |    388 |   \node (B) at (3.5,0) [node]
 | 
|  |    389 |      {\mbox{\includegraphics[scale=0.15]{../pics/robotron.jpg}}};
 | 
|  |    390 |   \node [above right] at (B.north west) {1988, C};
 | 
|  |    391 |   \draw [->,line width=4mm] (A) -- (B);}
 | 
|  |    392 | 
 | 
|  |    393 |   \onslide<3->{
 | 
|  |    394 |   \node (C0) at (6.3,0) {};
 | 
|  |    395 |   \node (C) at (8,0)  [node]
 | 
|  |    396 |      {\mbox{\includegraphics[scale=0.15]{../pics/sun.jpg}}};
 | 
|  |    397 |   \node [above right] at (C.north west) {1992, {\small Linux}};
 | 
|  |    398 |   \draw [->,line width=4mm] (B) -- (C0);
 | 
|  |    399 |   \draw [->,line width=4mm] (C0) -- (C);}
 | 
|  |    400 | 
 | 
|  |    401 |   \onslide<4->{
 | 
|  |    402 |   \node (D) at (8,-3.3)  [node]
 | 
|  |    403 |      {\mbox{\includegraphics[scale=0.2]{../pics/gateway.jpg}}};
 | 
|  |    404 |   \draw [->,line width=4mm] (C) -- (D);
 | 
|  |    405 |   \node [below right] at (D.south west) {1996};}
 | 
|  |    406 | 
 | 
|  |    407 |   \onslide<5->{
 | 
|  |    408 |   \node (E) at (4,-3.3)  [node]
 | 
|  |    409 |      {\mbox{\includegraphics[scale=0.1]{../pics/appleg4.jpg}}};
 | 
|  |    410 |   \draw [->,line width=4mm] (D) -- (E);
 | 
|  |    411 |   \node [above right] at (E.north west) {2000};}   
 | 
|  |    412 | 
 | 
|  |    413 |   \onslide<6->{
 | 
|  |    414 |   \node (F0) at (1.5,-3.3) {};
 | 
|  |    415 |   \node (F1) at (1,-3.3) {};
 | 
|  |    416 |   \node (F) at (-0.9,-3.3)  [node]
 | 
|  |    417 |      {\mbox{\includegraphics[scale=0.3]{../pics/appleair.png}}};
 | 
|  |    418 |   \draw [->,line width=4mm] (E) -- (F0);
 | 
|  |    419 |   \draw [->,line width=4mm] (F1) -- (F);   
 | 
|  |    420 |   \node [above right] at (F.north west) {2012?};}   
 | 
|  |    421 | 
 | 
|  |    422 |   \onslide<7->{
 | 
|  |    423 |   \node (G) at (-0.9,-6.3)  [node]
 | 
|  |    424 |      {\mbox{\includegraphics[scale=0.02]{../pics/applepro.jpg}}};
 | 
|  |    425 |   \draw [->,line width=4mm] (F) -- (G);
 | 
|  |    426 |   \node [right] at (G.west) {\hspace{22mm}2017};}   
 | 
|  |    427 |   
 | 
|  |    428 |   \end{tikzpicture}
 | 
|  |    429 |   \end{center}
 | 
|  |    430 | 
 | 
|  |    431 | 
 | 
|  |    432 |   \only<1>{%  
 | 
|  |    433 |     \begin{textblock}{10}(2.5,5)  
 | 
|  |    434 |       \includegraphics[scale=0.26]{../pics/cplus1.jpg}\\
 | 
|  |    435 |       \footnotesize 64K RAM, no HD, no monitor, lots of cables
 | 
|  |    436 |     \end{textblock}
 | 
|  |    437 |     \begin{textblock}{6}(10.9,4.5)  
 | 
|  |    438 |       \includegraphics[scale=0.09]{../pics/mand1.png}
 | 
|  |    439 |       \includegraphics[scale=0.09]{../pics/mand2.png}
 | 
|  |    440 |     \end{textblock}
 | 
|  |    441 |     \begin{textblock}{6}(10.8,2.2)  
 | 
|  |    442 |     \huge\bf 3 days
 | 
|  |    443 |     \end{textblock}
 | 
|  |    444 |   }
 | 
|  |    445 |   \only<8->{%
 | 
|  |    446 |   \begin{textblock}{8}(5.8,11.6)  
 | 
|  |    447 |     \large\bf
 | 
|  |    448 |     \begin{tabular}{l@{}l}
 | 
|  |    449 |       1986:\, & no Internet\\
 | 
|  |    450 |             & no Amazon\\
 | 
|  |    451 |             & no FB, no mobiles,\ldots\\ 
 | 
|  |    452 |     \end{tabular}         
 | 
|  |    453 |     \end{textblock}
 | 
|  |    454 |   }
 | 
|  |    455 |   \only<9>{
 | 
|  |    456 |   \begin{textblock}{1}(3,3)
 | 
|  |    457 |     \begin{bubble}[9cm]  
 | 
|  |    458 |       \begin{tabular}{@{\hspace{8mm}}llll@{\hspace{8mm}}}
 | 
|  |    459 |         \\
 | 
| 200 |    460 |       \multicolumn{4}{c}{\alert{\bf Speedup by Moore's Law}}\medskip\\
 | 
| 137 |    461 |       \textbf{1986:} & 3 days    & \textbf{1996:} & 135 mins\\
 | 
|  |    462 |       \textbf{1988:} & 1.5 days  & \textbf{1998:} & 67 mins\\
 | 
|  |    463 |       \textbf{1990:} & 18 hs     & \textbf{2000:} & 33 mins\\
 | 
|  |    464 |       \textbf{1992:} & 9 hs      & \textbf{2002:} & 16 mins\\
 | 
|  |    465 |       \textbf{1994:} & 4.5 hs    & \multicolumn{2}{c}{???}\\                    
 | 
|  |    466 |       \\
 | 
|  |    467 |       \end{tabular}
 | 
|  |    468 |       \small Every two years, computers got twice as powerful.
 | 
|  |    469 |   \end{bubble}
 | 
|  |    470 |   \end{textblock}}
 | 
|  |    471 | 
 | 
|  |    472 | \end{frame}
 | 
|  |    473 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    474 | 
 | 
|  |    475 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    476 | \begin{frame}[c]
 | 
| 200 |    477 | \frametitle{Seq \;vs\; Par}
 | 
| 137 |    478 | 
 | 
|  |    479 | \begin{center}
 | 
|  |    480 |   \begin{tabular}[t]{@{}l@{}l@{}}
 | 
| 200 |    481 |     \includegraphics[scale=0.14]{../pics/mand4.png} & \hspace{4mm}
 | 
|  |    482 |     \raisebox{0mm}{\includegraphics[scale=0.14]{../pics/mand3.png}}\\
 | 
|  |    483 |     \hspace{6mm}\includegraphics[scale=0.5]{../pics/cpu2.png} &
 | 
|  |    484 |     \hspace{11mm}\includegraphics[scale=0.5]{../pics/cpu1.png}
 | 
| 137 |    485 |   \end{tabular}     
 | 
|  |    486 | \end{center}  
 | 
|  |    487 | 
 | 
|  |    488 | \only<2>{
 | 
|  |    489 |   \begin{textblock}{5}(12,2)
 | 
|  |    490 |     \begin{bubble}[2.1cm]
 | 
|  |    491 |       \footnotesize{}in Java or C++\\
 | 
|  |    492 |       \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
 | 
|  |    493 |     \end{bubble}  
 | 
|  |    494 |   \end{textblock}}
 | 
|  |    495 | 
 | 
|  |    496 | \only<3>{
 | 
| 200 |    497 |   \begin{textblock}{14.2}(1,13.5)
 | 
| 140 |    498 |     In FP: Once a variable is created, it is assigned a value and then
 | 
| 308 |    499 |     never changed again $\Rightarrow$ no synchronisation needed\smallskip\\
 | 
| 200 |    500 |     %%\small\textcolor{gray}{(Andrew's second favourite feature of C++)}
 | 
| 137 |    501 |   \end{textblock}}
 | 
|  |    502 | 
 | 
|  |    503 | \end{frame}
 | 
|  |    504 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |    505 | 
 | 
| 354 |    506 | %\begin{frame}
 | 
|  |    507 | %
 | 
|  |    508 | %\end{frame}  
 | 
| 137 |    509 | 
 | 
| 354 |    510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    511 | %\begin{frame}[c, fragile]
 | 
|  |    512 | %
 | 
|  |    513 | %\mbox{}\bigskip\bigskip\bigskip
 | 
|  |    514 | %  
 | 
|  |    515 | %\begin{lstlisting}[language=Scala,numbers=none]
 | 
|  |    516 | %for (y <- (0 until H).par) {
 | 
|  |    517 | %  for (x <- (0 until W).par) {
 | 
|  |    518 | %    
 | 
|  |    519 | %    ...
 | 
|  |    520 | %    
 | 
|  |    521 | %  }  
 | 
|  |    522 | %}    
 | 
|  |    523 | %\end{lstlisting}
 | 
|  |    524 | %
 | 
|  |    525 | %  
 | 
|  |    526 | %\end{frame}
 | 
|  |    527 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 32 |    528 | 
 | 
|  |    529 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    530 | \begin{frame}[c]
 | 
| 23 |    531 | \frametitle{Types}
 | 
|  |    532 | 
 | 
|  |    533 | \begin{itemize}
 | 
| 33 |    534 | \item Base types\smallskip
 | 
| 23 |    535 | 
 | 
| 33 |    536 |   \begin{tabular}{@{}l@{}}
 | 
| 23 |    537 |     \textcolor{codegreen}{\texttt{Int}},
 | 
|  |    538 |     \textcolor{codegreen}{\texttt{Long}},
 | 
|  |    539 |     \textcolor{codegreen}{\texttt{BigInt}},
 | 
|  |    540 |     \textcolor{codegreen}{\texttt{Float}},
 | 
|  |    541 |     \textcolor{codegreen}{\texttt{Double}}\\
 | 
|  |    542 |     \textcolor{codegreen}{\texttt{String}},
 | 
| 25 |    543 |     \textcolor{codegreen}{\texttt{Char}}\\
 | 
|  |    544 |     \textcolor{codegreen}{\texttt{Boolean}}
 | 
| 23 |    545 |   \end{tabular}
 | 
|  |    546 | 
 | 
| 33 |    547 | \item Compound types \smallskip   
 | 
| 23 |    548 | 
 | 
| 33 |    549 |   \begin{tabular}{@{}ll@{}}
 | 
| 23 |    550 |     \textcolor{codegreen}{\texttt{List[Int]}}     & lists of Int's \\
 | 
|  |    551 |     \textcolor{codegreen}{\texttt{Set[Double]}}   & sets of Double's \\
 | 
|  |    552 |     \textcolor{codegreen}{\texttt{(Int, String)}} & Int-String pair\\
 | 
|  |    553 |     \textcolor{codegreen}{\texttt{List[(BigInt, String)]}} &
 | 
|  |    554 |                                       lists of BigInt-String\\
 | 
|  |    555 |                                       & pairs\\
 | 
| 200 |    556 |     \textcolor{codegreen}{\texttt{List[List[Int]]}} & list of lists of Int's\\      \textcolor{codegreen}{\texttt{Option[Int]}}     & options of Int's \\                            
 | 
| 23 |    557 |   \end{tabular}
 | 
|  |    558 | 
 | 
|  |    559 | \end{itemize}  
 | 
|  |    560 | 
 | 
|  |    561 | \end{frame}
 | 
|  |    562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    563 | 
 | 
| 32 |    564 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 200 |    565 | %\begin{frame}[c]
 | 
|  |    566 | %\frametitle{An Http Request}
 | 
| 32 |    567 |   
 | 
| 200 |    568 | %\begin{textblock}{1}(2,5)
 | 
|  |    569 | %\begin{tabular}{c}
 | 
|  |    570 | %\includegraphics[scale=0.15]{../pics/servers.png}\\[-2mm]
 | 
|  |    571 | %\small Server
 | 
|  |    572 | %\end{tabular}
 | 
|  |    573 | %\end{textblock}
 | 
| 32 |    574 | 
 | 
| 200 |    575 | %\begin{textblock}{1}(5.6,4)
 | 
|  |    576 | %  \begin{tikzpicture}[scale=1.1]
 | 
|  |    577 | %  \draw[white] (0,1) node (X) {};
 | 
|  |    578 | %  \draw[white] (2,1) node (Y) {};
 | 
|  |    579 | %   \draw[white] (0,0) node (X1) {};
 | 
|  |    580 | %  \draw[white] (2,0) node (Y1) {};
 | 
|  |    581 | %   \draw[white] (0,-1) node (X2) {};
 | 
|  |    582 | %  \draw[white] (2,-1) node (Y2) {};
 | 
|  |    583 | %  \draw[red, <-, line width = 2mm] (X) -- (Y);
 | 
|  |    584 | %  \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
 | 
|  |    585 | %  \draw[red, ->, line width = 2mm] (X1) -- (Y1);
 | 
|  |    586 | %  \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
 | 
|  |    587 | %  \draw[red, <-, line width = 2mm] (X2) -- (Y2);
 | 
|  |    588 | %  \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
 | 
|  |    589 | %  \end{tikzpicture}
 | 
|  |    590 | %\end{textblock}
 | 
| 32 |    591 | 
 | 
|  |    592 | 
 | 
| 200 |    593 | %\begin{textblock}{1}(9,5.5)
 | 
|  |    594 | %\begin{tabular}{c}
 | 
|  |    595 | %\includegraphics[scale=0.15]{../pics/laptop.png}\\[-2mm]
 | 
|  |    596 | %\small Browser
 | 
|  |    597 | %\end{tabular}
 | 
|  |    598 | %\end{textblock}
 | 
|  |    599 | %\end{frame}
 | 
| 32 |    600 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    601 | 
 | 
|  |    602 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 200 |    603 | %\begin{frame}[c]
 | 
|  |    604 | %
 | 
|  |    605 | %{\lstset{language=Java}\fontsize{7}{8}\selectfont
 | 
|  |    606 | %\texttt{\lstinputlisting{URLReader.java}}}
 | 
|  |    607 | %
 | 
|  |    608 | %\end{frame}
 | 
| 32 |    609 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    610 | 
 | 
| 33 |    611 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 356 |    612 | \begin{frame}[c, fragile]
 | 
| 359 |    613 | %%\frametitle{General Scheme of}  
 | 
| 356 |    614 | 
 | 
| 358 |    615 |  \small
 | 
|  |    616 | \begin{lstlisting}[language=Scala,numbers=none]
 | 
|  |    617 | def fname(arg1: ty1, arg2: ty2,..., argn: tyn): rty = {
 | 
| 356 |    618 | 
 | 
| 358 |    619 |    ....
 | 
| 356 |    620 | 
 | 
|  |    621 | }
 | 
|  |    622 | \end{lstlisting}
 | 
|  |    623 | 
 | 
|  |    624 |   
 | 
|  |    625 | \end{frame}
 | 
|  |    626 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    627 | 
 | 
| 359 |    628 | \begin{frame}[c, fragile]
 | 
|  |    629 | 
 | 
|  |    630 | \begin{lstlisting}[language=Scala,numbers=none]
 | 
|  |    631 | def average(xs: List[Int]) : Int = {
 | 
|  |    632 |   val s = xs.sum
 | 
|  |    633 |   val n = xs.length
 | 
|  |    634 |   s / n
 | 
|  |    635 | }
 | 
|  |    636 | \end{lstlisting}
 | 
|  |    637 | 
 | 
|  |    638 |   
 | 
|  |    639 | \end{frame}
 | 
|  |    640 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    641 |  
 | 
|  |    642 | 
 | 
|  |    643 | 
 | 
|  |    644 | 
 | 
| 309 |    645 | 
 | 
| 356 |    646 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    647 | %\begin{frame}[c]
 | 
|  |    648 | %  \frametitle{Coursework Dates}
 | 
|  |    649 | %  
 | 
|  |    650 | %Similar to C++:\bigskip
 | 
|  |    651 | %
 | 
|  |    652 | %\begin{itemize}
 | 
|  |    653 | %  \item Preliminary Parts: Wednesdays 4pm
 | 
|  |    654 | %    \begin{itemize}
 | 
|  |    655 | %      \item Preliminary Part 6: 3\% (13 November)
 | 
|  |    656 | %      \item Preliminary Part 7: 4\% (20 November)
 | 
|  |    657 | %      \item Preliminary Part 8: 4\% (27 November)
 | 
|  |    658 | %      \item Preliminary Part 9: 4\% (5 December) 
 | 
|  |    659 | %    \end{itemize}\medskip    
 | 
|  |    660 | %  \item Core Part: 35\% (15 January 2020)\bigskip 
 | 
|  |    661 | %\end{itemize}
 | 
|  |    662 | %\end{frame}
 | 
|  |    663 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 309 |    664 |   
 | 
|  |    665 | 
 | 
|  |    666 | 
 | 
|  |    667 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 356 |    668 | %\begin{frame}[c]
 | 
|  |    669 | %\frametitle{Coursework}
 | 
|  |    670 | %
 | 
|  |    671 | %\begin{itemize}
 | 
|  |    672 | %\item Sorry, I might have been a bit wordy:\\
 | 
|  |    673 | %  Part 6 of CW description is 7 pages, but
 | 
|  |    674 | %  I only needed \mbox{< 100} loc for \emph{all} Part 6.\bigskip
 | 
|  |    675 | %
 | 
|  |    676 | %\item there is feedback when pushing code to github\medskip
 | 
|  |    677 | %
 | 
|  |    678 | %\item there are \texttt{jar}-files you can use to test 
 | 
|  |    679 | %  my reference implementation\bigskip
 | 
|  |    680 | %  
 | 
|  |    681 | %\item we want you to learn FP!\smallskip\\ \alert{\bf no vars}, no mutable
 | 
|  |    682 | %  data-structures\\ \quad{}e.g.~no \texttt{Arrays}, no \texttt{ListBuffer}
 | 
|  |    683 | %\end{itemize}
 | 
|  |    684 | %
 | 
|  |    685 | %\LEFTarrow{1}{11}{11.8}
 | 
|  |    686 | %\end{frame}
 | 
| 140 |    687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    688 | 
 | 
|  |    689 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    690 | 
 | 
|  |    691 | \begin{frame}[c, fragile]
 | 
|  |    692 | \frametitle{The Joy of Immutability}
 | 
|  |    693 | 
 | 
|  |    694 | \begin{itemize}
 | 
|  |    695 | \item If you need to manipulate some data in a list say, then you make
 | 
|  |    696 |   a new list with the updated values, rather than revise the original
 | 
|  |    697 |   list. Easy!\medskip
 | 
|  |    698 | 
 | 
|  |    699 |   {\small
 | 
|  |    700 |   \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    701 |     val old_list = List(1, 2, 3, 5)
 | 
|  |    702 |     val new_list = 0 :: old_list
 | 
| 308 |    703 |                 // -> List(0, 1, 2, 3, 4, 5)
 | 
| 140 |    704 |   \end{lstlisting}}  
 | 
|  |    705 |   
 | 
| 200 |    706 | \item You do not have to be defensive about who can access the data.
 | 
|  |    707 | 
 | 
|  |    708 | \item You can look at your code in isolation.  
 | 
| 140 |    709 | \end{itemize}  
 | 
|  |    710 | \end{frame}
 | 
|  |    711 | 
 | 
|  |    712 | 
 | 
|  |    713 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    714 | 
 | 
|  |    715 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    716 | \begin{frame}[t]
 | 
|  |    717 | \frametitle{Email: Hate 'val'}
 | 
|  |    718 | 
 | 
| 308 |    719 | \mbox{}\\[-23mm]\mbox{}
 | 
| 140 |    720 | 
 | 
|  |    721 | \begin{center}
 | 
|  |    722 |   \begin{bubble}[10.5cm]
 | 
| 354 |    723 |   Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\hspace{1cm}\medskip\\
 | 
| 140 |    724 | 
 | 
|  |    725 |   Hello Mr Urban,\medskip\\
 | 
|  |    726 | 
 | 
|  |    727 |   I just wanted to ask, how are we suppose to work
 | 
|  |    728 |   with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
 | 
|  |    729 |   this rule active at all? I’ve spent 4 hours not thinking on the
 | 
|  |    730 |   coursework, but how to bypass this annoying rule. What’s the whole
 | 
|  |    731 |   point of all these coursework, when we can’t use everything Scala
 | 
|  |    732 |   gives us?!?\medskip\\
 | 
|  |    733 | 
 | 
|  |    734 |   Regards.\\
 | 
|  |    735 |   \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
 | 
|  |    736 |   \end{bubble}
 | 
|  |    737 | \end{center}
 | 
|  |    738 | 
 | 
|  |    739 | \end{frame}
 | 
|  |    740 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    741 | 
 | 
|  |    742 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    743 | \begin{frame}[c]
 | 
|  |    744 | 
 | 
|  |    745 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    746 | 
 | 
|  |    747 | \begin{center}
 | 
|  |    748 |   \begin{bubble}[10.5cm]
 | 
| 354 |    749 |   Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\hspace{1cm}\bigskip\bigskip\\
 | 
| 140 |    750 | 
 | 
|  |    751 |   \textcolor{black!70}{
 | 
|  |    752 |     \textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
 | 
|  |    753 |     yada>>}}\bigskip\bigskip\bigskip
 | 
|  |    754 |   
 | 
|  |    755 |   PS: What are you trying to do where you desperately want to use \texttt{var}?
 | 
|  |    756 |   \end{bubble}
 | 
|  |    757 | \end{center}
 | 
|  |    758 | 
 | 
|  |    759 | \end{frame}
 | 
|  |    760 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    761 | 
 | 
|  |    762 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    763 | \begin{frame}[c,fragile]
 | 
|  |    764 | 
 | 
|  |    765 | \begin{textblock}{6}(0.5,0.5)
 | 
|  |    766 | \begin{bubble}[11.5cm]
 | 
|  |    767 |   \small  
 | 
| 354 |    768 |   Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\hspace{1cm}\medskip\\
 | 
| 140 |    769 | 
 | 
|  |    770 |   \textbf{Right now my is\_legal function works fine:}
 | 
|  |    771 |   
 | 
|  |    772 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    773 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
 | 
|  |    774 |    var boolReturn = false
 | 
|  |    775 |    if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
 | 
|  |    776 |    else { var breakLoop = false
 | 
|  |    777 |           if(path == Nil) { boolReturn = true }
 | 
|  |    778 |           else { for(i <- 0 until path.length) {
 | 
|  |    779 |                     if(breakLoop == false) {
 | 
|  |    780 |                       if(path(i) == x) {
 | 
|  |    781 |                         boolReturn = true
 | 
|  |    782 |                         breakLoop = true
 | 
|  |    783 |                       }
 | 
|  |    784 |                       else { boolReturn = false }
 | 
|  |    785 |                     } else breakLoop
 | 
|  |    786 |             }
 | 
|  |    787 |           }
 | 
|  |    788 |           boolReturn
 | 
|  |    789 |    }
 | 
|  |    790 | \end{lstlisting}
 | 
|  |    791 | \end{bubble}
 | 
|  |    792 | \end{textblock}
 | 
|  |    793 | 
 | 
|  |    794 | \begin{textblock}{6}(8.2,11.8)
 | 
|  |    795 | \begin{bubble}[5.5cm]\footnotesize\bf
 | 
|  |    796 | \ldots{}but I can’t make it work with boolReturn being val. What approach would
 | 
|  |    797 | you recommend in this case, and is using var in this case justified?
 | 
|  |    798 | \end{bubble}
 | 
|  |    799 | \end{textblock}
 | 
|  |    800 | 
 | 
|  |    801 | \only<2>{
 | 
|  |    802 | \begin{textblock}{6}(0.3,11.8)
 | 
|  |    803 |   \begin{bubble}[3.1cm]
 | 
|  |    804 |     \textbf{Me:}
 | 
|  |    805 |     \raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}}
 | 
|  |    806 |   \end{bubble}
 | 
|  |    807 | \end{textblock}}
 | 
|  |    808 | 
 | 
|  |    809 | \end{frame}
 | 
|  |    810 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    811 | 
 | 
|  |    812 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    813 | \begin{frame}[t,fragile]
 | 
|  |    814 | 
 | 
|  |    815 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    816 | 
 | 
|  |    817 | \begin{textblock}{6}(0.5,2)
 | 
|  |    818 |   \begin{bubble}[11.5cm]
 | 
|  |    819 |   Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
 | 
|  |    820 |   \small
 | 
|  |    821 |   
 | 
|  |    822 |   OK. So you want to make sure that the \texttt{x}-position is not outside the
 | 
|  |    823 |   board....and furthermore you want to make sure that the \texttt{x}-position
 | 
|  |    824 |   is not yet in the path list. How about something like\bigskip
 | 
|  |    825 | 
 | 
|  |    826 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    827 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = 
 | 
|  |    828 |    ...<<some board conditions>>... && !path.contains(x)
 | 
|  |    829 | \end{lstlisting}\bigskip
 | 
|  |    830 |   
 | 
|  |    831 |   \small Does not even contain a \texttt{val}.
 | 
|  |    832 |   \end{bubble}
 | 
|  |    833 | \end{textblock}
 | 
|  |    834 | 
 | 
|  |    835 | \begin{textblock}{6}(7,12)
 | 
|  |    836 | \footnotesize\textcolor{black!50}{(This is all on one line)}
 | 
|  |    837 | \end{textblock}
 | 
|  |    838 | 
 | 
|  |    839 | \end{frame}
 | 
|  |    840 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    841 | 
 | 
|  |    842 | 
 | 
|  |    843 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    844 | \begin{frame}[t,fragile]
 | 
|  |    845 | 
 | 
|  |    846 | \mbox{}\\[-15mm]\mbox{}
 | 
|  |    847 | 
 | 
|  |    848 | \begin{textblock}{6}(1,3)
 | 
|  |    849 |   \begin{bubble}[10.5cm]
 | 
|  |    850 |     Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
 | 
|  |    851 |     
 | 
|  |    852 |     THANK YOU! You made me change my coding perspective. Because of you,
 | 
|  |    853 |     I figured out the next one\ldots
 | 
|  |    854 |   \end{bubble}
 | 
|  |    855 | \end{textblock}
 | 
|  |    856 | 
 | 
|  |    857 | \only<2>{
 | 
|  |    858 | \begin{textblock}{6}(0.3,11.8)
 | 
|  |    859 |   \begin{bubble}[3.1cm]
 | 
|  |    860 |     \textbf{Me:}
 | 
|  |    861 |     \raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}}
 | 
|  |    862 |   \end{bubble}
 | 
|  |    863 | \end{textblock}}
 | 
|  |    864 | 
 | 
|  |    865 | \end{frame}
 | 
|  |    866 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    867 | 
 | 
| 424 |    868 | \begin{frame}[t,fragile]
 | 
|  |    869 | 
 | 
|  |    870 | \begin{bubble}[10.5cm]
 | 
|  |    871 |   "PEP was my favourite module so far during these 2 years. It motivated me to apply and get a summer internship offer at S\&P Global as a Scala developer. The module content was more than enough for me to start working on the projects here at the company." -- Szabolcs Daniel Nagi (PEP 2021)
 | 
|  |    872 | \end{bubble}  
 | 
|  |    873 | \end{frame}
 | 
|  |    874 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    875 | 
 | 
| 140 |    876 | 
 | 
|  |    877 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    878 | \begin{frame}[c]
 | 
| 309 |    879 | \frametitle{Conclusion for Today}
 | 
| 33 |    880 | 
 | 
|  |    881 | \begin{itemize}
 | 
| 309 |    882 | \item Scala is still under development, 2.13.1 came out in Sept.\\ 
 | 
|  |    883 |   (the compiler is terribly slow)\medskip
 | 
| 33 |    884 | \item {\bf\url{http://www.scala-lang.org/}}\bigskip
 | 
| 140 |    885 |   
 | 
|  |    886 | \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives
 | 
|  |    887 |   you a lot of rope to shoot yourself\bigskip
 | 
| 33 |    888 | 
 | 
| 140 |    889 | \item learning functional programming is not easy\ldots{}when you have
 | 
| 200 |    890 |   spent all of your career thinking in an imperative way, it is hard to
 | 
| 140 |    891 |   change\bigskip\medskip
 | 
|  |    892 |   
 | 
| 200 |    893 | \item hope you have fun with Scala and the assignments
 | 
| 33 |    894 | \end{itemize}
 | 
|  |    895 | \end{frame}
 | 
|  |    896 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    897 | 
 | 
|  |    898 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 356 |    899 | %\begin{frame}[c]
 | 
|  |    900 | %\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
 | 
|  |    901 | %
 | 
|  |    902 | %\begin{center}
 | 
|  |    903 | %  \begin{tabular}[t]{@{}l@{}l@{}}
 | 
|  |    904 | %    \includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
 | 
|  |    905 | %    \raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
 | 
|  |    906 | %  \end{tabular}     
 | 
|  |    907 | %\end{center}
 | 
|  |    908 | %
 | 
|  |    909 | %\begin{center}
 | 
|  |    910 | %  My Office Hours: Thursdays 12 -- 14\\
 | 
|  |    911 | %  And specifically for Scala: Tuesdays 10:45 -- 11:45
 | 
|  |    912 | %\end{center}
 | 
|  |    913 | %\end{frame}
 | 
| 33 |    914 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 314 |    915 | 
 | 
|  |    916 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 356 |    917 | %\begin{frame}[t]%
 | 
|  |    918 | %
 | 
|  |    919 | %\begin{center}  
 | 
|  |    920 | %\includegraphics[scale=0.4]{../pics/blow.png}
 | 
|  |    921 | %\end{center}
 | 
|  |    922 | %
 | 
|  |    923 | %\begin{textblock}{14}(2,12.4)
 | 
|  |    924 | %\Large\bf{}Mind-Blowing\\ Programming Languages: C/C++
 | 
|  |    925 | %\end{textblock}
 | 
|  |    926 | %\end{frame}
 | 
| 314 |    927 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    928 | 
 | 
| 360 |    929 | \begin{frame}[c]
 | 
|  |    930 | \begin{center}
 | 
|  |    931 | \includegraphics[scale=0.4]{../pics/fun.png}
 | 
|  |    932 | \end{center}
 | 
|  |    933 | \end{frame}
 | 
| 32 |    934 | 
 | 
| 413 |    935 | \begin{frame}<1-20>[t]
 | 
| 360 |    936 |   
 | 
|  |    937 | \end{frame}
 | 
| 32 |    938 | 
 | 
| 22 |    939 | \end{document}
 | 
|  |    940 | 
 | 
|  |    941 | %%% Local Variables:  
 | 
|  |    942 | %%% mode: latex
 | 
|  |    943 | %%% TeX-master: t
 | 
|  |    944 | %%% End: 
 | 
|  |    945 | 
 | 
| 140 |    946 | 
 | 
|  |    947 | “Functional programming is often regarded as the best-kept secret of
 | 
|  |    948 | scientific modelers, mathematicians, artificial intelligence
 | 
|  |    949 | researchers, financial institutions, graphic designers, CPU designers,
 | 
|  |    950 | compiler programmers, and telecommunications engineers.”
 | 
|  |    951 | 
 | 
|  |    952 | The Wikipedia F# page |