| 22 |      1 | \documentclass[dvipsnames,14pt,t,xelatex]{beamer}
 | 
|  |      2 | \usepackage{../slides}
 | 
| 32 |      3 | \usepackage{../graphics}
 | 
| 22 |      4 | \usepackage{../langs}
 | 
|  |      5 | %\usepackage{../data}
 | 
|  |      6 | 
 | 
|  |      7 | \hfuzz=220pt 
 | 
|  |      8 | 
 | 
|  |      9 | %\setmonofont[Scale=.88]{Consolas}
 | 
|  |     10 | %\newfontfamily{\consolas}{Consolas}
 | 
|  |     11 | 
 | 
|  |     12 | \lstset{language=Scala,
 | 
|  |     13 |         style=mystyle,
 | 
|  |     14 |         numbersep=0pt,
 | 
|  |     15 |         numbers=none,
 | 
|  |     16 |         xleftmargin=0mm}
 | 
|  |     17 | 
 | 
|  |     18 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
|  |     19 | 
 | 
|  |     20 | % beamer stuff 
 | 
| 195 |     21 | \renewcommand{\slidecaption}{PEP (Scala) \liningnums{01}, King's College London}
 | 
| 22 |     22 | 
 | 
|  |     23 | 
 | 
|  |     24 | \begin{document}
 | 
|  |     25 | 
 | 
|  |     26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     27 | \begin{frame}[t]
 | 
|  |     28 | \frametitle{%
 | 
|  |     29 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |     30 |   \\[5mm]
 | 
| 199 |     31 |   \hspace{7mm}\huge PEP Scala (\liningnums{1}) 
 | 
| 22 |     32 |   \end{tabular}}
 | 
|  |     33 | 
 | 
|  |     34 |   \normalsize
 | 
|  |     35 |   \begin{center}
 | 
|  |     36 |   \begin{tabular}{ll}
 | 
| 137 |     37 |     Email:  & christian.urban at kcl.ac.uk\\
 | 
| 195 |     38 |     Office: & N\liningnums{7.07} (North Wing, Bush House)\\
 | 
| 137 |     39 |     Slides \& Code: & KEATS\medskip\\
 | 
| 199 |     40 |     Office Hours: &  Mondays 12:00 -- 14:00\\
 | 
|  |     41 |            & \alert{except next week: Tuesday}
 | 
| 22 |     42 |   \end{tabular}
 | 
|  |     43 |   \end{center}
 | 
|  |     44 | 
 | 
| 199 |     45 |   %\tiny
 | 
|  |     46 |   %developed since 2004 bv Martin Odersky
 | 
|  |     47 |   %picture about assignments
 | 
|  |     48 | 
 | 
|  |     49 | \begin{textblock}{6}(0.5,0.5)
 | 
|  |     50 | \includegraphics[scale=0.035]{../pics/assign.jpg}\\[-1mm]
 | 
|  |     51 | \end{textblock}
 | 
| 22 |     52 | 
 | 
|  |     53 | \end{frame}
 | 
|  |     54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |     55 | 
 | 
|  |     56 | 
 | 
|  |     57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     58 | \begin{frame}[c]
 | 
|  |     59 | \frametitle{Why Scala?}
 | 
|  |     60 | 
 | 
| 23 |     61 | \begin{textblock}{6}(3,4)
 | 
| 22 |     62 | \begin{tabular}{l}
 | 
|  |     63 | \mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
 | 
|  |     64 | \includegraphics[scale=0.30]{../pics/linked.png}\\
 | 
| 141 |     65 | \includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
 | 
| 22 |     66 | \mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
 | 
|  |     67 | \includegraphics[scale=0.30]{../pics/suisse.png}\\
 | 
| 23 |     68 | {\large\bf ...}
 | 
|  |     69 | \end{tabular}
 | 
|  |     70 | \end{textblock}
 | 
|  |     71 | 
 | 
|  |     72 | \begin{textblock}{6}(9,4)
 | 
|  |     73 | \begin{tabular}{l}
 | 
| 22 |     74 | \includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
 | 
|  |     75 | \includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
 | 
|  |     76 | \includegraphics[scale=0.30]{../pics/foursquare.png}\\
 | 
|  |     77 | \includegraphics[scale=0.30]{../pics/hsbc.png}\\
 | 
|  |     78 | {\large\bf ...}
 | 
|  |     79 | \end{tabular}
 | 
|  |     80 | \end{textblock}
 | 
|  |     81 | 
 | 
| 199 |     82 | 
 | 
|  |     83 | \begin{textblock}{6}(2,12)
 | 
|  |     84 | \begin{bubble}[9cm]
 | 
|  |     85 |   \small
 | 
|  |     86 |   developed since 2004 by Martin Odersky\\
 | 
|  |     87 |   (he was behind Generic Scala which was included in Java 5)
 | 
|  |     88 | \end{bubble}
 | 
|  |     89 | \end{textblock}
 | 
|  |     90 | 
 | 
| 22 |     91 | \end{frame}
 | 
|  |     92 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |     93 | 
 | 
| 174 |     94 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 199 |     95 | %\begin{frame}[c]
 | 
|  |     96 | %\frametitle{Why Scala?}
 | 
|  |     97 | %
 | 
|  |     98 | %In the last few years there is  a ``Cambrian explosion'' of
 | 
|  |     99 | %languages from both academia and industry.
 | 
|  |    100 | %
 | 
|  |    101 | %It is essential for students to have skills to pick up new languages
 | 
|  |    102 | %quickly.
 | 
|  |    103 | %
 | 
|  |    104 | %\end{frame}
 | 
| 174 |    105 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    106 | 
 | 
| 23 |    107 | 
 | 
|  |    108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    109 | \begin{frame}[c]
 | 
|  |    110 | \frametitle{Why Scala?}
 | 
|  |    111 | 
 | 
|  |    112 | \begin{itemize}
 | 
| 34 |    113 | \item compiles to the JVM\\
 | 
|  |    114 |   \textcolor{gray}{(also JavaScript, native X86 in the works)}\medskip
 | 
| 32 |    115 | \item integrates seamlessly with Java\medskip
 | 
| 33 |    116 | \item combines \underline{\bf functional} and {\bf object-oriented} programming\bigskip
 | 
| 34 |    117 | \item it is a bit on the ``mathematical'' side\\
 | 
| 199 |    118 |   \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
 | 
| 34 |    119 |   
 | 
| 33 |    120 | \item often one can write very concise and elegant code
 | 
|  |    121 | \end{itemize}\bigskip\medskip  
 | 
|  |    122 | 
 | 
|  |    123 | \small
 | 
| 137 |    124 | alternatives:\\
 | 
| 140 |    125 | Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots
 | 
| 23 |    126 | 
 | 
|  |    127 | \end{frame}
 | 
| 22 |    128 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 23 |    129 | 
 | 
|  |    130 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    131 | \begin{frame}[c]
 | 
| 32 |    132 | \frametitle{Java vs Scala}
 | 
|  |    133 | 
 | 
|  |    134 | {\lstset{language=java}\fontsize{12}{12}\selectfont
 | 
|  |    135 | \texttt{\lstinputlisting{Point.java}}}
 | 
|  |    136 | 
 | 
| 33 |    137 | \rule{11cm}{0.3mm}\\[-2mm]
 | 
|  |    138 | 
 | 
| 32 |    139 | {\lstset{language=scala}\fontsize{12}{12}\selectfont
 | 
|  |    140 | \texttt{\lstinputlisting{Point.scala}}}
 | 
|  |    141 | 
 | 
|  |    142 | \begin{textblock}{6}(13,3)
 | 
|  |    143 | \textbf{\large Java}
 | 
| 33 |    144 | \end{textblock}
 | 
|  |    145 | 
 | 
|  |    146 | \begin{textblock}{6}(13,13.4)
 | 
| 32 |    147 | \textbf{\large Scala}
 | 
|  |    148 | \end{textblock}  
 | 
|  |    149 | 
 | 
|  |    150 | \end{frame}
 | 
|  |    151 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    152 | 
 | 
| 33 |    153 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 199 |    154 | %\begin{frame}[c]
 | 
|  |    155 | %\frametitle{Scala (imperative) vs Scala (functional)}
 | 
|  |    156 | %
 | 
|  |    157 | %Reham's example
 | 
|  |    158 | %
 | 
|  |    159 | %
 | 
|  |    160 | %\end{frame}
 | 
| 174 |    161 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    162 | 
 | 
|  |    163 | 
 | 
|  |    164 | 
 | 
|  |    165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    166 | \begin{frame}[c]
 | 
| 137 |    167 | \frametitle{First Steps: Scala Tools}
 | 
| 32 |    168 | 
 | 
| 33 |    169 | \begin{itemize}
 | 
| 199 |    170 | \item I use VS Code and a Scala extension
 | 
|  |    171 | \begin{center}  
 | 
|  |    172 | \includegraphics[scale=0.10]{../pics/vscode.png}\\[-10mm]\mbox{}
 | 
|  |    173 | \end{center}\bigskip
 | 
|  |    174 |   
 | 
| 33 |    175 | \item there is a plugin for Eclipse (called Scala IDE)\medskip
 | 
| 137 |    176 | \item there is also a plugin for IntelliJ\medskip
 | 
| 33 |    177 | \end{itemize}  
 | 
|  |    178 | 
 | 
|  |    179 | \end{frame}
 | 
| 137 |    180 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    181 | 
 | 
|  |    182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    183 | \begin{frame}[c]
 | 
|  |    184 |   \frametitle{\bf
 | 
|  |    185 |   \only<1>{\begin{tabular}{l}\\[2mm]Why Scala?\\ \mbox{}\end{tabular}}
 | 
|  |    186 |   \only<2->{\begin{tabular}{l}\\[2mm]Why Functional\\ Programming?\end{tabular}}
 | 
|  |    187 | }
 | 
|  |    188 | 
 | 
|  |    189 | 
 | 
|  |    190 |   %
 | 
|  |    191 |   \mbox{}\\[3.5cm]
 | 
|  |    192 |   \small
 | 
| 140 |    193 | Scala, Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots 
 | 
| 137 |    194 | 
 | 
|  |    195 | \only<3>{
 | 
|  |    196 | \begin{textblock}{6}(2,6.2)
 | 
|  |    197 | \begin{bubble}[10cm]
 | 
|  |    198 | \normalsize``If you want to see which features will be in mainstream programming
 | 
|  |    199 |   languages tomorrow, then take a look at functional programming
 | 
|  |    200 |   languages today.''\medskip\small\\
 | 
|  |    201 |   \hfill{}---Simon Peyton Jones (works at Microsoft)\\
 | 
|  |    202 |   \hfill{}main developer of the Glasgow Haskell Compiler
 | 
|  |    203 | \end{bubble}
 | 
|  |    204 | \end{textblock}}
 | 
|  |    205 | 
 | 
|  |    206 | \end{frame}
 | 
|  |    207 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    208 | 
 | 
|  |    209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    210 | \begin{frame}[c]
 | 
|  |    211 | \mbox{}\\[-21mm]\mbox{}  
 | 
|  |    212 | 
 | 
|  |    213 | \begin{center}
 | 
|  |    214 |   \begin{tikzpicture}[scale=1,
 | 
|  |    215 |                       node/.style={
 | 
|  |    216 |                       rectangle,rounded corners=3mm,
 | 
|  |    217 |                       very thick,draw=black!50,
 | 
|  |    218 |                       minimum height=18mm, minimum width=20mm,
 | 
|  |    219 |                       top color=white,bottom color=black!20}]
 | 
|  |    220 | 
 | 
|  |    221 |   \onslide<1-10>{                
 | 
|  |    222 |   \node (A) at (0,0) [node]
 | 
|  |    223 |      {\mbox{\includegraphics[scale=0.15]{../pics/cplus2.jpg}}};
 | 
|  |    224 |   \node [above right] at (A.north west) {1986};}
 | 
|  |    225 | 
 | 
|  |    226 |   \onslide<2->{
 | 
|  |    227 |   \node (B) at (3.5,0) [node]
 | 
|  |    228 |      {\mbox{\includegraphics[scale=0.15]{../pics/robotron.jpg}}};
 | 
|  |    229 |   \node [above right] at (B.north west) {1988, C};
 | 
|  |    230 |   \draw [->,line width=4mm] (A) -- (B);}
 | 
|  |    231 | 
 | 
|  |    232 |   \onslide<3->{
 | 
|  |    233 |   \node (C0) at (6.3,0) {};
 | 
|  |    234 |   \node (C) at (8,0)  [node]
 | 
|  |    235 |      {\mbox{\includegraphics[scale=0.15]{../pics/sun.jpg}}};
 | 
|  |    236 |   \node [above right] at (C.north west) {1992, {\small Linux}};
 | 
|  |    237 |   \draw [->,line width=4mm] (B) -- (C0);
 | 
|  |    238 |   \draw [->,line width=4mm] (C0) -- (C);}
 | 
|  |    239 | 
 | 
|  |    240 |   \onslide<4->{
 | 
|  |    241 |   \node (D) at (8,-3.3)  [node]
 | 
|  |    242 |      {\mbox{\includegraphics[scale=0.2]{../pics/gateway.jpg}}};
 | 
|  |    243 |   \draw [->,line width=4mm] (C) -- (D);
 | 
|  |    244 |   \node [below right] at (D.south west) {1996};}
 | 
|  |    245 | 
 | 
|  |    246 |   \onslide<5->{
 | 
|  |    247 |   \node (E) at (4,-3.3)  [node]
 | 
|  |    248 |      {\mbox{\includegraphics[scale=0.1]{../pics/appleg4.jpg}}};
 | 
|  |    249 |   \draw [->,line width=4mm] (D) -- (E);
 | 
|  |    250 |   \node [above right] at (E.north west) {2000};}   
 | 
|  |    251 | 
 | 
|  |    252 |   \onslide<6->{
 | 
|  |    253 |   \node (F0) at (1.5,-3.3) {};
 | 
|  |    254 |   \node (F1) at (1,-3.3) {};
 | 
|  |    255 |   \node (F) at (-0.9,-3.3)  [node]
 | 
|  |    256 |      {\mbox{\includegraphics[scale=0.3]{../pics/appleair.png}}};
 | 
|  |    257 |   \draw [->,line width=4mm] (E) -- (F0);
 | 
|  |    258 |   \draw [->,line width=4mm] (F1) -- (F);   
 | 
|  |    259 |   \node [above right] at (F.north west) {2012?};}   
 | 
|  |    260 | 
 | 
|  |    261 |   \onslide<7->{
 | 
|  |    262 |   \node (G) at (-0.9,-6.3)  [node]
 | 
|  |    263 |      {\mbox{\includegraphics[scale=0.02]{../pics/applepro.jpg}}};
 | 
|  |    264 |   \draw [->,line width=4mm] (F) -- (G);
 | 
|  |    265 |   \node [right] at (G.west) {\hspace{22mm}2017};}   
 | 
|  |    266 |   
 | 
|  |    267 |   \end{tikzpicture}
 | 
|  |    268 |   \end{center}
 | 
|  |    269 | 
 | 
|  |    270 | 
 | 
|  |    271 |   \only<1>{%  
 | 
|  |    272 |     \begin{textblock}{10}(2.5,5)  
 | 
|  |    273 |       \includegraphics[scale=0.26]{../pics/cplus1.jpg}\\
 | 
|  |    274 |       \footnotesize 64K RAM, no HD, no monitor, lots of cables
 | 
|  |    275 |     \end{textblock}
 | 
|  |    276 |     \begin{textblock}{6}(10.9,4.5)  
 | 
|  |    277 |       \includegraphics[scale=0.09]{../pics/mand1.png}
 | 
|  |    278 |       \includegraphics[scale=0.09]{../pics/mand2.png}
 | 
|  |    279 |     \end{textblock}
 | 
|  |    280 |     \begin{textblock}{6}(10.8,2.2)  
 | 
|  |    281 |     \huge\bf 3 days
 | 
|  |    282 |     \end{textblock}
 | 
|  |    283 |   }
 | 
|  |    284 |   \only<8->{%
 | 
|  |    285 |   \begin{textblock}{8}(5.8,11.6)  
 | 
|  |    286 |     \large\bf
 | 
|  |    287 |     \begin{tabular}{l@{}l}
 | 
|  |    288 |       1986:\, & no Internet\\
 | 
|  |    289 |             & no Amazon\\
 | 
|  |    290 |             & no FB, no mobiles,\ldots\\ 
 | 
|  |    291 |     \end{tabular}         
 | 
|  |    292 |     \end{textblock}
 | 
|  |    293 |   }
 | 
|  |    294 |   \only<9>{
 | 
|  |    295 |   \begin{textblock}{1}(3,3)
 | 
|  |    296 |     \begin{bubble}[9cm]  
 | 
|  |    297 |       \begin{tabular}{@{\hspace{8mm}}llll@{\hspace{8mm}}}
 | 
|  |    298 |         \\
 | 
|  |    299 |       \multicolumn{4}{c}{\bf Speedup by Moore's Law}\medskip\\
 | 
|  |    300 |       \textbf{1986:} & 3 days    & \textbf{1996:} & 135 mins\\
 | 
|  |    301 |       \textbf{1988:} & 1.5 days  & \textbf{1998:} & 67 mins\\
 | 
|  |    302 |       \textbf{1990:} & 18 hs     & \textbf{2000:} & 33 mins\\
 | 
|  |    303 |       \textbf{1992:} & 9 hs      & \textbf{2002:} & 16 mins\\
 | 
|  |    304 |       \textbf{1994:} & 4.5 hs    & \multicolumn{2}{c}{???}\\                    
 | 
|  |    305 |       \\
 | 
|  |    306 |       \end{tabular}
 | 
|  |    307 |       \small Every two years, computers got twice as powerful.
 | 
|  |    308 |   \end{bubble}
 | 
|  |    309 |   \end{textblock}}
 | 
|  |    310 | 
 | 
|  |    311 | \end{frame}
 | 
|  |    312 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    313 | 
 | 
|  |    314 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    315 | \begin{frame}[c]
 | 
|  |    316 | \frametitle{Seq vs Par}
 | 
|  |    317 | 
 | 
|  |    318 | \begin{center}
 | 
|  |    319 |   \begin{tabular}[t]{@{}l@{}l@{}}
 | 
|  |    320 |     \includegraphics[scale=0.14]{../pics/mand4.png} &
 | 
|  |    321 |     \raisebox{1.2mm}{\includegraphics[scale=0.14]{../pics/mand3.png}}      
 | 
|  |    322 |   \end{tabular}     
 | 
|  |    323 | \end{center}  
 | 
|  |    324 | 
 | 
|  |    325 | \only<2>{
 | 
|  |    326 |   \begin{textblock}{5}(12,2)
 | 
|  |    327 |     \begin{bubble}[2.1cm]
 | 
|  |    328 |       \footnotesize{}in Java or C++\\
 | 
|  |    329 |       \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
 | 
|  |    330 |     \end{bubble}  
 | 
|  |    331 |   \end{textblock}}
 | 
|  |    332 | 
 | 
|  |    333 | \only<3>{
 | 
| 140 |    334 |   \begin{textblock}{14.2}(1,12.3)
 | 
|  |    335 |     In FP: Once a variable is created, it is assigned a value and then
 | 
|  |    336 |     never changed again $\Rightarrow$ no synchronisation\smallskip\\
 | 
|  |    337 |     \small\textcolor{gray}{(Andrew's second favourite feature of C++)}
 | 
| 137 |    338 |   \end{textblock}}
 | 
|  |    339 | 
 | 
|  |    340 | \end{frame}
 | 
|  |    341 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |    342 | 
 | 
|  |    343 | 
 | 
|  |    344 | 
 | 
| 32 |    345 | 
 | 
|  |    346 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    347 | \begin{frame}[c]
 | 
| 23 |    348 | \frametitle{Types}
 | 
|  |    349 | 
 | 
|  |    350 | \begin{itemize}
 | 
| 33 |    351 | \item Base types\smallskip
 | 
| 23 |    352 | 
 | 
| 33 |    353 |   \begin{tabular}{@{}l@{}}
 | 
| 23 |    354 |     \textcolor{codegreen}{\texttt{Int}},
 | 
|  |    355 |     \textcolor{codegreen}{\texttt{Long}},
 | 
|  |    356 |     \textcolor{codegreen}{\texttt{BigInt}},
 | 
|  |    357 |     \textcolor{codegreen}{\texttt{Float}},
 | 
|  |    358 |     \textcolor{codegreen}{\texttt{Double}}\\
 | 
|  |    359 |     \textcolor{codegreen}{\texttt{String}},
 | 
| 25 |    360 |     \textcolor{codegreen}{\texttt{Char}}\\
 | 
|  |    361 |     \textcolor{codegreen}{\texttt{Boolean}}
 | 
| 23 |    362 |   \end{tabular}
 | 
|  |    363 | 
 | 
| 33 |    364 | \item Compound types \smallskip   
 | 
| 23 |    365 | 
 | 
| 33 |    366 |   \begin{tabular}{@{}ll@{}}
 | 
| 23 |    367 |     \textcolor{codegreen}{\texttt{List[Int]}}     & lists of Int's \\
 | 
|  |    368 |     \textcolor{codegreen}{\texttt{Set[Double]}}   & sets of Double's \\
 | 
|  |    369 |     \textcolor{codegreen}{\texttt{(Int, String)}} & Int-String pair\\
 | 
|  |    370 |     \textcolor{codegreen}{\texttt{List[(BigInt, String)]}} &
 | 
|  |    371 |                                       lists of BigInt-String\\
 | 
|  |    372 |                                       & pairs\\
 | 
| 26 |    373 |     \textcolor{codegreen}{\texttt{List[List[Int]]}} & list of lists of Int's\\                                  
 | 
| 23 |    374 |   \end{tabular}
 | 
|  |    375 | 
 | 
|  |    376 | \end{itemize}  
 | 
|  |    377 | 
 | 
|  |    378 | \end{frame}
 | 
|  |    379 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    380 | 
 | 
| 32 |    381 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    382 | \begin{frame}[c]
 | 
|  |    383 | \frametitle{An Http Request}
 | 
|  |    384 |   
 | 
|  |    385 | \begin{textblock}{1}(2,5)
 | 
|  |    386 | \begin{tabular}{c}
 | 
|  |    387 | \includegraphics[scale=0.15]{../pics/servers.png}\\[-2mm]
 | 
|  |    388 | \small Server
 | 
|  |    389 | \end{tabular}
 | 
|  |    390 | \end{textblock}
 | 
|  |    391 | 
 | 
|  |    392 | \begin{textblock}{1}(5.6,4)
 | 
|  |    393 |   \begin{tikzpicture}[scale=1.1]
 | 
|  |    394 |   \draw[white] (0,1) node (X) {};
 | 
|  |    395 |   \draw[white] (2,1) node (Y) {};
 | 
|  |    396 |    \draw[white] (0,0) node (X1) {};
 | 
|  |    397 |   \draw[white] (2,0) node (Y1) {};
 | 
|  |    398 |    \draw[white] (0,-1) node (X2) {};
 | 
|  |    399 |   \draw[white] (2,-1) node (Y2) {};
 | 
|  |    400 |   \draw[red, <-, line width = 2mm] (X) -- (Y);
 | 
|  |    401 |   \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
 | 
|  |    402 |   \draw[red, ->, line width = 2mm] (X1) -- (Y1);
 | 
|  |    403 |   \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
 | 
|  |    404 |   \draw[red, <-, line width = 2mm] (X2) -- (Y2);
 | 
|  |    405 |   \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
 | 
|  |    406 |   \end{tikzpicture}
 | 
|  |    407 | \end{textblock}
 | 
|  |    408 | 
 | 
|  |    409 | 
 | 
|  |    410 | \begin{textblock}{1}(9,5.5)
 | 
|  |    411 | \begin{tabular}{c}
 | 
|  |    412 | \includegraphics[scale=0.15]{../pics/laptop.png}\\[-2mm]
 | 
|  |    413 | \small Browser
 | 
|  |    414 | \end{tabular}
 | 
|  |    415 | \end{textblock}
 | 
|  |    416 | \end{frame}
 | 
|  |    417 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    418 | 
 | 
|  |    419 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    420 | \begin{frame}[c]
 | 
|  |    421 | 
 | 
|  |    422 | {\lstset{language=Java}\fontsize{7}{8}\selectfont
 | 
|  |    423 | \texttt{\lstinputlisting{URLReader.java}}}
 | 
|  |    424 | 
 | 
|  |    425 | \end{frame}
 | 
|  |    426 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    427 | 
 | 
| 33 |    428 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    429 | \begin{frame}[c]
 | 
| 140 |    430 | \frametitle{Coursework}
 | 
|  |    431 | 
 | 
|  |    432 | \begin{itemize}
 | 
|  |    433 | \item sorry, I might have been a bit wordy:\\
 | 
|  |    434 |   CW description is 7 pages, but
 | 
| 142 |    435 |   I only needed \mbox{< 150} loc for all the CW\bigskip
 | 
| 140 |    436 | 
 | 
|  |    437 | \item there is email feedback when pushing code to github\bigskip
 | 
|  |    438 | 
 | 
|  |    439 | \item we want you to learn FP: \alert{no vars}, no mutable
 | 
|  |    440 |   datastructures, e.g.~\texttt{ListBuffer}
 | 
|  |    441 | \end{itemize}
 | 
|  |    442 | \end{frame}
 | 
|  |    443 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    444 | 
 | 
|  |    445 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    446 | 
 | 
|  |    447 | \begin{frame}[c, fragile]
 | 
|  |    448 | \frametitle{The Joy of Immutability}
 | 
|  |    449 | 
 | 
|  |    450 | \begin{itemize}
 | 
|  |    451 | \item If you need to manipulate some data in a list say, then you make
 | 
|  |    452 |   a new list with the updated values, rather than revise the original
 | 
|  |    453 |   list. Easy!\medskip
 | 
|  |    454 | 
 | 
|  |    455 |   {\small
 | 
|  |    456 |   \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    457 |     val old_list = List(1, 2, 3, 5)
 | 
|  |    458 |     val new_list = 0 :: old_list
 | 
|  |    459 |   \end{lstlisting}}  
 | 
|  |    460 |   
 | 
|  |    461 | \item You do not have to be defensive about who can access the data
 | 
|  |    462 |   (concurrency, lazyness).
 | 
|  |    463 | \end{itemize}  
 | 
|  |    464 | \end{frame}
 | 
|  |    465 | 
 | 
|  |    466 | 
 | 
|  |    467 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    468 | 
 | 
|  |    469 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    470 | \begin{frame}[t]
 | 
|  |    471 | \frametitle{Email: Hate 'val'}
 | 
|  |    472 | 
 | 
|  |    473 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    474 | 
 | 
|  |    475 | \begin{center}
 | 
|  |    476 |   \begin{bubble}[10.5cm]
 | 
|  |    477 |   Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
 | 
|  |    478 | 
 | 
|  |    479 |   Hello Mr Urban,\medskip\\
 | 
|  |    480 | 
 | 
|  |    481 |   I just wanted to ask, how are we suppose to work
 | 
|  |    482 |   with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
 | 
|  |    483 |   this rule active at all? I’ve spent 4 hours not thinking on the
 | 
|  |    484 |   coursework, but how to bypass this annoying rule. What’s the whole
 | 
|  |    485 |   point of all these coursework, when we can’t use everything Scala
 | 
|  |    486 |   gives us?!?\medskip\\
 | 
|  |    487 | 
 | 
|  |    488 |   Regards.\\
 | 
|  |    489 |   \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
 | 
|  |    490 |   \end{bubble}
 | 
|  |    491 | \end{center}
 | 
|  |    492 | 
 | 
|  |    493 | \end{frame}
 | 
|  |    494 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    495 | 
 | 
|  |    496 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    497 | \begin{frame}[c]
 | 
|  |    498 | 
 | 
|  |    499 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    500 | 
 | 
|  |    501 | \begin{center}
 | 
|  |    502 |   \begin{bubble}[10.5cm]
 | 
|  |    503 |   Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
 | 
|  |    504 | 
 | 
|  |    505 |   \textcolor{black!70}{
 | 
|  |    506 |     \textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
 | 
|  |    507 |     yada>>}}\bigskip\bigskip\bigskip
 | 
|  |    508 |   
 | 
|  |    509 |   PS: What are you trying to do where you desperately want to use \texttt{var}?
 | 
|  |    510 |   \end{bubble}
 | 
|  |    511 | \end{center}
 | 
|  |    512 | 
 | 
|  |    513 | \end{frame}
 | 
|  |    514 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    515 | 
 | 
|  |    516 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    517 | \begin{frame}[c,fragile]
 | 
|  |    518 | 
 | 
|  |    519 | \begin{textblock}{6}(0.5,0.5)
 | 
|  |    520 | \begin{bubble}[11.5cm]
 | 
|  |    521 |   \small  
 | 
|  |    522 |   Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\
 | 
|  |    523 | 
 | 
|  |    524 |   \textbf{Right now my is\_legal function works fine:}
 | 
|  |    525 |   
 | 
|  |    526 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    527 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
 | 
|  |    528 |    var boolReturn = false
 | 
|  |    529 |    if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
 | 
|  |    530 |    else { var breakLoop = false
 | 
|  |    531 |           if(path == Nil) { boolReturn = true }
 | 
|  |    532 |           else { for(i <- 0 until path.length) {
 | 
|  |    533 |                     if(breakLoop == false) {
 | 
|  |    534 |                       if(path(i) == x) {
 | 
|  |    535 |                         boolReturn = true
 | 
|  |    536 |                         breakLoop = true
 | 
|  |    537 |                       }
 | 
|  |    538 |                       else { boolReturn = false }
 | 
|  |    539 |                     } else breakLoop
 | 
|  |    540 |             }
 | 
|  |    541 |           }
 | 
|  |    542 |           boolReturn
 | 
|  |    543 |    }
 | 
|  |    544 | \end{lstlisting}
 | 
|  |    545 | \end{bubble}
 | 
|  |    546 | \end{textblock}
 | 
|  |    547 | 
 | 
|  |    548 | \begin{textblock}{6}(8.2,11.8)
 | 
|  |    549 | \begin{bubble}[5.5cm]\footnotesize\bf
 | 
|  |    550 | \ldots{}but I can’t make it work with boolReturn being val. What approach would
 | 
|  |    551 | you recommend in this case, and is using var in this case justified?
 | 
|  |    552 | \end{bubble}
 | 
|  |    553 | \end{textblock}
 | 
|  |    554 | 
 | 
|  |    555 | \only<2>{
 | 
|  |    556 | \begin{textblock}{6}(0.3,11.8)
 | 
|  |    557 |   \begin{bubble}[3.1cm]
 | 
|  |    558 |     \textbf{Me:}
 | 
|  |    559 |     \raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}}
 | 
|  |    560 |   \end{bubble}
 | 
|  |    561 | \end{textblock}}
 | 
|  |    562 | 
 | 
|  |    563 | \end{frame}
 | 
|  |    564 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    565 | 
 | 
|  |    566 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    567 | \begin{frame}[t,fragile]
 | 
|  |    568 | 
 | 
|  |    569 | \mbox{}\\[-25mm]\mbox{}
 | 
|  |    570 | 
 | 
|  |    571 | \begin{textblock}{6}(0.5,2)
 | 
|  |    572 |   \begin{bubble}[11.5cm]
 | 
|  |    573 |   Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
 | 
|  |    574 |   \small
 | 
|  |    575 |   
 | 
|  |    576 |   OK. So you want to make sure that the \texttt{x}-position is not outside the
 | 
|  |    577 |   board....and furthermore you want to make sure that the \texttt{x}-position
 | 
|  |    578 |   is not yet in the path list. How about something like\bigskip
 | 
|  |    579 | 
 | 
|  |    580 | \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    581 |  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = 
 | 
|  |    582 |    ...<<some board conditions>>... && !path.contains(x)
 | 
|  |    583 | \end{lstlisting}\bigskip
 | 
|  |    584 |   
 | 
|  |    585 |   \small Does not even contain a \texttt{val}.
 | 
|  |    586 |   \end{bubble}
 | 
|  |    587 | \end{textblock}
 | 
|  |    588 | 
 | 
|  |    589 | \begin{textblock}{6}(7,12)
 | 
|  |    590 | \footnotesize\textcolor{black!50}{(This is all on one line)}
 | 
|  |    591 | \end{textblock}
 | 
|  |    592 | 
 | 
|  |    593 | \end{frame}
 | 
|  |    594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    595 | 
 | 
|  |    596 | 
 | 
|  |    597 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    598 | \begin{frame}[t,fragile]
 | 
|  |    599 | 
 | 
|  |    600 | \mbox{}\\[-15mm]\mbox{}
 | 
|  |    601 | 
 | 
|  |    602 | \begin{textblock}{6}(1,3)
 | 
|  |    603 |   \begin{bubble}[10.5cm]
 | 
|  |    604 |     Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
 | 
|  |    605 |     
 | 
|  |    606 |     THANK YOU! You made me change my coding perspective. Because of you,
 | 
|  |    607 |     I figured out the next one\ldots
 | 
|  |    608 |   \end{bubble}
 | 
|  |    609 | \end{textblock}
 | 
|  |    610 | 
 | 
|  |    611 | \only<2>{
 | 
|  |    612 | \begin{textblock}{6}(0.3,11.8)
 | 
|  |    613 |   \begin{bubble}[3.1cm]
 | 
|  |    614 |     \textbf{Me:}
 | 
|  |    615 |     \raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}}
 | 
|  |    616 |   \end{bubble}
 | 
|  |    617 | \end{textblock}}
 | 
|  |    618 | 
 | 
|  |    619 | \end{frame}
 | 
|  |    620 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    621 | 
 | 
|  |    622 | 
 | 
|  |    623 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    624 | \begin{frame}[c]
 | 
| 33 |    625 | \frametitle{Conclusion}
 | 
|  |    626 | 
 | 
|  |    627 | \begin{itemize}
 | 
|  |    628 | \item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip
 | 
|  |    629 | \item {\bf\url{http://www.scala-lang.org/}}\bigskip
 | 
| 140 |    630 |   
 | 
|  |    631 | \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives
 | 
|  |    632 |   you a lot of rope to shoot yourself\bigskip
 | 
| 33 |    633 | 
 | 
| 140 |    634 | \item learning functional programming is not easy\ldots{}when you have
 | 
|  |    635 |   spent all of your career thinking in a procedural way it is hard to
 | 
|  |    636 |   change\bigskip\medskip
 | 
|  |    637 |   
 | 
| 33 |    638 | \item hope you have fun with the coursework  
 | 
|  |    639 | \end{itemize}
 | 
|  |    640 | \end{frame}
 | 
|  |    641 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    642 | 
 | 
|  |    643 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    644 | \begin{frame}[c]
 | 
| 140 |    645 | \frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
 | 
| 33 |    646 | 
 | 
| 140 |    647 | \begin{center}
 | 
|  |    648 |   \begin{tabular}[t]{@{}l@{}l@{}}
 | 
|  |    649 |     \includegraphics[scale=0.1]{../pics/mand4.png} &
 | 
|  |    650 |     \raisebox{1.2mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
 | 
|  |    651 |   \end{tabular}     
 | 
|  |    652 | \end{center}
 | 
|  |    653 | 
 | 
|  |    654 | \begin{center}
 | 
|  |    655 | My Scala Office Hours: Thursdays 11 -- 13
 | 
|  |    656 | \end{center}
 | 
| 33 |    657 | \end{frame}
 | 
|  |    658 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    659 | \end{document}
 | 
| 32 |    660 | 
 | 
|  |    661 | 
 | 
| 22 |    662 | \end{document}
 | 
|  |    663 | 
 | 
|  |    664 | %%% Local Variables:  
 | 
|  |    665 | %%% mode: latex
 | 
|  |    666 | %%% TeX-master: t
 | 
|  |    667 | %%% End: 
 | 
|  |    668 | 
 | 
| 140 |    669 | 
 | 
|  |    670 | “Functional programming is often regarded as the best-kept secret of
 | 
|  |    671 | scientific modelers, mathematicians, artificial intelligence
 | 
|  |    672 | researchers, financial institutions, graphic designers, CPU designers,
 | 
|  |    673 | compiler programmers, and telecommunications engineers.”
 | 
|  |    674 | 
 | 
|  |    675 | The Wikipedia F# page |