| 327 |      1 | % !TEX program = xelatex
 | 
| 383 |      2 | \documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
 | 
| 451 |      3 | \usepackage{../styles/slides}
 | 
|  |      4 | \usepackage{../styles/mygraphs}
 | 
|  |      5 | \usepackage{../styles/langs}
 | 
| 452 |      6 | \usepackage{chessboard} 
 | 
| 239 |      7 | %%\usepackage{../data}
 | 
| 327 |      8 | %%\usepackage[export]{adjustbox}
 | 
|  |      9 | \usetikzlibrary{shapes,arrows,shadows}
 | 
|  |     10 | 
 | 
| 239 |     11 | 
 | 
| 415 |     12 | % Swift, example (a*)*b  
 | 
|  |     13 | \begin{filecontents}{re-swift.data}
 | 
|  |     14 | 5   0.001
 | 
|  |     15 | 10  0.001
 | 
|  |     16 | 15  0.009
 | 
|  |     17 | 20  0.178
 | 
|  |     18 | 23  1.399
 | 
|  |     19 | 24  2.893
 | 
|  |     20 | 25  5.671
 | 
|  |     21 | 26  11.357
 | 
|  |     22 | 27  22.430
 | 
|  |     23 | \end{filecontents}
 | 
|  |     24 | 
 | 
|  |     25 | % Dart, example (a*)*b  
 | 
|  |     26 | \begin{filecontents}{re-dart.data}
 | 
|  |     27 | 20 0.042
 | 
|  |     28 | 21 0.084
 | 
|  |     29 | 22 0.190
 | 
|  |     30 | 23 0.340
 | 
|  |     31 | 24 0.678
 | 
|  |     32 | 25 1.369
 | 
|  |     33 | 26 2.700
 | 
|  |     34 | 27 5.462
 | 
|  |     35 | 28 10.908
 | 
|  |     36 | 29 21.725
 | 
|  |     37 | 30 43.492
 | 
|  |     38 | \end{filecontents}
 | 
|  |     39 | 
 | 
|  |     40 | 
 | 
|  |     41 | \begin{filecontents}{re3a.data}
 | 
|  |     42 | 1 0.00003
 | 
|  |     43 | 500001 0.22527
 | 
|  |     44 | 1000001 0.62752
 | 
|  |     45 | 1500001 0.88485
 | 
|  |     46 | 2000001 1.39815
 | 
|  |     47 | 2500001 1.68619
 | 
|  |     48 | 3000001 1.94957
 | 
|  |     49 | 3500001 2.15878
 | 
|  |     50 | 4000001 2.59918
 | 
|  |     51 | 4500001 5.90679
 | 
|  |     52 | 5000001 13.11295
 | 
|  |     53 | 5500001 19.15376
 | 
|  |     54 | 6000001 40.16373
 | 
|  |     55 | \end{filecontents}
 | 
|  |     56 | \begin{filecontents}{re-python2.data}
 | 
|  |     57 | 1 0.033
 | 
|  |     58 | 5 0.036
 | 
|  |     59 | 10 0.034
 | 
|  |     60 | 15 0.036
 | 
|  |     61 | 18 0.059
 | 
|  |     62 | 19 0.084
 | 
|  |     63 | 20 0.141
 | 
|  |     64 | 21 0.248
 | 
|  |     65 | 22 0.485
 | 
|  |     66 | 23 0.878
 | 
|  |     67 | 24 1.71
 | 
|  |     68 | 25 3.40
 | 
|  |     69 | 26 7.08
 | 
|  |     70 | 27 14.12
 | 
|  |     71 | 28 26.69
 | 
|  |     72 | \end{filecontents}
 | 
|  |     73 | 
 | 
|  |     74 | \begin{filecontents}{re-js.data}
 | 
|  |     75 | 5   0.061
 | 
|  |     76 | 10  0.061
 | 
|  |     77 | 15  0.061
 | 
|  |     78 | 20  0.070
 | 
|  |     79 | 23  0.131
 | 
|  |     80 | 25  0.308
 | 
|  |     81 | 26  0.564
 | 
|  |     82 | 28  1.994
 | 
|  |     83 | 30  7.648
 | 
|  |     84 | 31  15.881 
 | 
|  |     85 | 32  32.190
 | 
|  |     86 | \end{filecontents}
 | 
|  |     87 | 
 | 
|  |     88 | \begin{filecontents}{re-java.data}
 | 
|  |     89 | 5  0.00298
 | 
|  |     90 | 10  0.00418
 | 
|  |     91 | 15  0.00996
 | 
|  |     92 | 16  0.01710
 | 
|  |     93 | 17  0.03492
 | 
|  |     94 | 18  0.03303
 | 
|  |     95 | 19  0.05084
 | 
|  |     96 | 20  0.10177
 | 
|  |     97 | 21  0.19960
 | 
|  |     98 | 22  0.41159
 | 
|  |     99 | 23  0.82234
 | 
|  |    100 | 24  1.70251
 | 
|  |    101 | 25  3.36112
 | 
|  |    102 | 26  6.63998
 | 
|  |    103 | 27  13.35120
 | 
|  |    104 | 28  29.81185
 | 
|  |    105 | \end{filecontents}
 | 
|  |    106 | 
 | 
|  |    107 | \begin{filecontents}{re-java9.data}
 | 
|  |    108 | 1000  0.01410
 | 
|  |    109 | 2000  0.04882
 | 
|  |    110 | 3000  0.10609
 | 
|  |    111 | 4000  0.17456
 | 
|  |    112 | 5000  0.27530
 | 
|  |    113 | 6000  0.41116
 | 
|  |    114 | 7000  0.53741
 | 
|  |    115 | 8000  0.70261
 | 
|  |    116 | 9000  0.93981
 | 
|  |    117 | 10000 0.97419
 | 
|  |    118 | 11000 1.28697
 | 
|  |    119 | 12000 1.51387
 | 
|  |    120 | 14000 2.07079
 | 
|  |    121 | 16000 2.69846
 | 
|  |    122 | 20000 4.41823
 | 
|  |    123 | 24000 6.46077
 | 
|  |    124 | 26000 7.64373
 | 
|  |    125 | 30000 9.99446
 | 
|  |    126 | 34000 12.966885
 | 
|  |    127 | 38000 16.281621
 | 
|  |    128 | 42000 19.180228
 | 
|  |    129 | 46000 21.984721
 | 
|  |    130 | 50000 26.950203
 | 
|  |    131 | 60000 43.0327746
 | 
|  |    132 | \end{filecontents}
 | 
|  |    133 | 
 | 
|  |    134 | 
 | 
| 239 |    135 | \hfuzz=220pt 
 | 
|  |    136 | 
 | 
|  |    137 | %\setmonofont[Scale=.88]{Consolas}
 | 
|  |    138 | %\newfontfamily{\consolas}{Consolas}
 | 
|  |    139 | 
 | 
|  |    140 | \lstset{language=Scala,
 | 
|  |    141 |         style=mystyle,
 | 
|  |    142 |         numbersep=0pt,
 | 
|  |    143 |         numbers=none,
 | 
|  |    144 |         xleftmargin=0mm}
 | 
|  |    145 | 
 | 
|  |    146 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
|  |    147 | 
 | 
|  |    148 | % beamer stuff 
 | 
|  |    149 | \renewcommand{\slidecaption}{PEP (Scala) 05, King's College London}
 | 
|  |    150 | 
 | 
|  |    151 | \begin{document}
 | 
|  |    152 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    153 | \begin{frame}[t]
 | 
|  |    154 | \frametitle{%
 | 
|  |    155 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |    156 |   \\[5mm]
 | 
|  |    157 |   \huge PEP Scala (5) 
 | 
|  |    158 |   \end{tabular}}
 | 
|  |    159 | 
 | 
|  |    160 |   \normalsize
 | 
|  |    161 |   \begin{center}
 | 
|  |    162 |   \begin{tabular}{ll}
 | 
|  |    163 |     Email:  & christian.urban at kcl.ac.uk\\
 | 
| 383 |    164 |     %Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
 | 
| 415 |    165 |     Slides \& Code: & KEATS\bigskip\\
 | 
| 451 |    166 | 
 | 
| 479 |    167 |     Office Hour: &  Fridays 13:00 -- 14:00\\
 | 
| 451 |    168 |     Location: & N7.07 (North Wing, Bush House)\bigskip\\
 | 
|  |    169 | 
 | 
|  |    170 |     Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\  \\
 | 
| 239 |    171 |   \end{tabular}
 | 
|  |    172 |   \end{center}
 | 
|  |    173 | 
 | 
|  |    174 | \end{frame}
 | 
|  |    175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    176 | 
 | 
| 451 |    177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    178 | \begin{frame}[t]
 | 
|  |    179 | \frametitle{Housekeeping}
 | 
|  |    180 | 
 | 
|  |    181 | \mbox{}\medskip  
 | 
|  |    182 | 
 | 
|  |    183 | \begin{minipage}{1.2\textwidth}
 | 
|  |    184 | \begin{itemize}
 | 
|  |    185 | \item SGTs still ongoing next week
 | 
| 479 |    186 | %\item LGT next week online: Ask-Me-Anything (will be recorded, TEAMS link will be emailed and published on KEATS)
 | 
|  |    187 | %\item tests might break over Christmas  
 | 
| 451 |    188 | \end{itemize}\bigskip
 | 
|  |    189 | 
 | 
| 479 |    190 | %\begin{center}
 | 
|  |    191 | %\raisebox{-9mm}{\includegraphics[scale=0.15]{../pics/thanks.jpeg}} Junhuai Hou \quad Chin Wan
 | 
|  |    192 | %\end{center}  
 | 
| 451 |    193 | \end{minipage}
 | 
|  |    194 | 
 | 
|  |    195 | 
 | 
|  |    196 | \end{frame}
 | 
| 415 |    197 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 451 |    198 | 
 | 
| 452 |    199 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 479 |    200 | %\begin{frame}[c]
 | 
|  |    201 | %\frametitle{Main 4: \knight-Tour}
 | 
|  |    202 | %
 | 
|  |    203 | %\begin{center}
 | 
|  |    204 | %\Large\bf hint
 | 
|  |    205 | %\end{center}  
 | 
|  |    206 | %
 | 
|  |    207 | %\end{frame}
 | 
| 452 |    208 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 451 |    209 | 
 | 
|  |    210 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    211 | \begin{frame}[c]
 | 
| 415 |    212 |   \frametitle{Main 3: Regexes}
 | 
|  |    213 |   
 | 
|  |    214 | \begin{center}
 | 
|  |    215 |   \mbox{Graphs: regex \alert{\texttt{(a*)*b}} and strings $\underbrace{\;\texttt{a}\ldots \texttt{a}\;}_{n}$}\bigskip
 | 
|  |    216 | 
 | 
|  |    217 |   \small  
 | 
|  |    218 | \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-0mm}}c@{}}
 | 
|  |    219 | \only<1>{\raisebox{6mm}{\begin{tikzpicture}
 | 
|  |    220 | \begin{axis}[
 | 
|  |    221 |     xlabel={$n$},
 | 
|  |    222 |     x label style={at={(1.05,0.0)}},
 | 
|  |    223 |     ylabel={time in secs},
 | 
|  |    224 |     enlargelimits=false,
 | 
|  |    225 |     xtick={0,5,...,30},
 | 
|  |    226 |     xmax=33,
 | 
|  |    227 |     ymax=35,
 | 
|  |    228 |     ytick={0,5,...,30},
 | 
|  |    229 |     scaled ticks=false,
 | 
|  |    230 |     axis lines=left,
 | 
|  |    231 |     width=5.5cm,
 | 
|  |    232 |     height=5cm,
 | 
|  |    233 |     legend entries={Java 8,Python,JavaScript,Swift,Dart},
 | 
|  |    234 |     %legend entries={\small{}Python,  \small{}Java 8,  \small{}JavaScript},  
 | 
|  |    235 |     legend pos=north west,
 | 
|  |    236 |     legend cell align=left]
 | 
|  |    237 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};  
 | 
|  |    238 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
|  |    239 | \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
|  |    240 | \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
|  |    241 | \addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data};
 | 
|  |    242 | \end{axis}
 | 
|  |    243 | \end{tikzpicture}}}%
 | 
|  |    244 | \only<2>{\raisebox{0mm}{\begin{tikzpicture}
 | 
|  |    245 | \begin{axis}[
 | 
|  |    246 |     xlabel={$n$},
 | 
|  |    247 |     x label style={at={(1.05,0.0)}},
 | 
|  |    248 |     ylabel={time in secs},
 | 
|  |    249 |     %y label style={at={(0.06,0.5)}},
 | 
|  |    250 |     enlargelimits=false,
 | 
|  |    251 |     %xtick={0,30000,...,60000},
 | 
|  |    252 |     xmax=65000,
 | 
|  |    253 |     ymax=35,
 | 
|  |    254 |     ytick={0,5,...,30},
 | 
|  |    255 |     scaled ticks=true,
 | 
|  |    256 |     axis lines=left,
 | 
|  |    257 |     width=5.5cm,
 | 
|  |    258 |     height=5cm, 
 | 
|  |    259 |     legend entries={\small{}Java 9},  
 | 
|  |    260 |     legend pos=north west]
 | 
|  |    261 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java9.data};
 | 
|  |    262 | \end{axis}
 | 
|  |    263 | \end{tikzpicture}}}
 | 
|  |    264 |   &
 | 
|  |    265 | \onslide<1-2>{\begin{tikzpicture}
 | 
|  |    266 |   \begin{axis}[
 | 
|  |    267 |     xlabel={$n$},
 | 
|  |    268 |     x label style={at={(1.05,0.0)}},
 | 
|  |    269 |     ylabel={time in secs},
 | 
|  |    270 |     enlargelimits=false,
 | 
|  |    271 |     ymax=35,
 | 
|  |    272 |     ytick={0,5,...,30},
 | 
|  |    273 |     axis lines=left,
 | 
|  |    274 |     legend entries={You in M3}, 
 | 
|  |    275 |     %%scaled ticks=false,
 | 
|  |    276 |     width=5.5cm, 
 | 
|  |    277 |     height=5cm]
 | 
|  |    278 | %%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data};    
 | 
|  |    279 | \addplot[magenta,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
|  |    280 | \end{axis}
 | 
|  |    281 | \end{tikzpicture}}
 | 
|  |    282 | \end{tabular}
 | 
|  |    283 | \end{center}
 | 
|  |    284 | 
 | 
|  |    285 | \hfill\small\url{https://vimeo.com/112065252}
 | 
|  |    286 | \end{frame}
 | 
|  |    287 | 
 | 
|  |    288 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    289 | 
 | 
|  |    290 | 
 | 
|  |    291 | 
 | 
| 240 |    292 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    293 | 
 | 
| 383 |    294 | %\begin{frame}[c]
 | 
|  |    295 | %\frametitle{Marks for Preliminary 8}
 | 
|  |    296 | %
 | 
|  |    297 | %Raw marks (265 submissions):\bigskip
 | 
|  |    298 | %
 | 
|  |    299 | %\begin{itemize}
 | 
|  |    300 | %\item 4\%: \hspace{4mm}211
 | 
|  |    301 | %\item 3\%: \hspace{4mm}11
 | 
|  |    302 | %\item 2\%: \hspace{4mm}14
 | 
|  |    303 | %\item 1\%: \hspace{4mm}8
 | 
|  |    304 | %\item 0\%: \hspace{4mm}21
 | 
|  |    305 | %\end{itemize}\bigskip\bigskip  
 | 
|  |    306 | %
 | 
|  |    307 | %\footnotesize
 | 
|  |    308 | %(plagiarism/collusion interviews ongoing again!)
 | 
|  |    309 | %
 | 
|  |    310 | %\end{frame}
 | 
| 327 |    311 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    312 | 
 | 
|  |    313 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    314 | 
 | 
| 479 |    315 | %\begin{frame}[c]
 | 
|  |    316 | %\frametitle{Plan for Today}
 | 
|  |    317 | %
 | 
|  |    318 | %\begin{itemize}
 | 
|  |    319 | %\item Polymorphic Types  
 | 
|  |    320 | %\item Implicits
 | 
|  |    321 | %\item Immutable OOP
 | 
|  |    322 | %%\item Making Fun about Scala
 | 
|  |    323 | %\end{itemize}
 | 
| 240 |    324 | 
 | 
| 479 |    325 | %\end{frame}
 | 
| 327 |    326 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    327 | 
 | 
|  |    328 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 451 |    329 | %\begin{frame}[c,fragile]
 | 
|  |    330 | %\frametitle{How To calcululate 100 Mio Collatz Series?} 
 | 
|  |    331 | %
 | 
|  |    332 | %\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
 | 
|  |    333 | %(1L to 100_000_000).map(collatz).max
 | 
|  |    334 | %\end{lstlisting}
 | 
|  |    335 | %
 | 
|  |    336 | %\end{frame}
 | 
| 327 |    337 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    338 | 
 | 
|  |    339 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    340 | \begin{frame}[c,fragile]
 | 
|  |    341 | \frametitle{Polyorphic Types} 
 | 
|  |    342 | 
 | 
| 451 |    343 | %To be avoided:\bigskip\bigskip
 | 
| 327 |    344 | \small
 | 
|  |    345 | 
 | 
|  |    346 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm]
 | 
|  |    347 | def length_string_list(lst: List[String]): Int = 
 | 
|  |    348 |  lst match {
 | 
|  |    349 |    case Nil => 0
 | 
|  |    350 |    case x::xs => 1 + length_string_list(xs)
 | 
|  |    351 |  }
 | 
| 240 |    352 | 
 | 
| 451 |    353 |  
 | 
| 327 |    354 | def length_int_list(lst: List[Int]): Int = 
 | 
|  |    355 |  lst match {
 | 
|  |    356 |    case Nil => 0
 | 
|  |    357 |    case x::xs => 1 + length_int_list(xs)
 | 
|  |    358 |  }
 | 
|  |    359 | \end{lstlisting}
 | 
|  |    360 | 
 | 
|  |    361 | \end{frame}
 | 
|  |    362 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    363 | 
 | 
|  |    364 | 
 | 
|  |    365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    366 | \begin{frame}[c,fragile]
 | 
|  |    367 | \frametitle{Polyorphic Types} 
 | 
|  |    368 | 
 | 
|  |    369 | \small
 | 
|  |    370 | 
 | 
|  |    371 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm]
 | 
|  |    372 | def length[A](lst: List[A]): Int = lst match {
 | 
|  |    373 |   case Nil => 0
 | 
|  |    374 |   case x::xs => 1 + length(xs)
 | 
|  |    375 | }
 | 
|  |    376 | 
 | 
|  |    377 | length(List("1", "2", "3", "4"))
 | 
|  |    378 | length(List(1, 2, 3, 4))
 | 
|  |    379 | 
 | 
|  |    380 | 
 | 
|  |    381 | def map[A, B](lst: List[A], f: A => B): List[B] = 
 | 
|  |    382 |  lst match {
 | 
|  |    383 |    case Nil => Nil
 | 
|  |    384 |    case x::xs => f(x)::map(xs, f) 
 | 
|  |    385 |  }
 | 
|  |    386 | \end{lstlisting}
 | 
|  |    387 | \end{frame}
 | 
| 240 |    388 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    389 | 
 | 
|  |    390 | 
 | 
|  |    391 | 
 | 
| 239 |    392 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 327 |    393 | \begin{frame}[c]
 | 
|  |    394 | \frametitle{DFAs}  
 | 
|  |    395 | 
 | 
|  |    396 | \begin{center}
 | 
|  |    397 | \begin{tikzpicture}[>=stealth',very thick,auto,
 | 
|  |    398 |   every state/.style={minimum size=0pt,inner sep=2pt,
 | 
|  |    399 |     draw=blue!50,very thick,fill=blue!20},]
 | 
| 239 |    400 |   
 | 
| 327 |    401 | \only<1,3->{\node[state,initial] (Q_0)  {$\mbox{Q}_0$};}
 | 
|  |    402 | \only<2>{\node[state,initial,fill=red] (Q_0)  {$\mbox{Q}_0$};}  
 | 
|  |    403 | \only<1,2,4->{\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};}
 | 
|  |    404 | \only<3>{\node[state,fill=red] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};}
 | 
|  |    405 | \only<-3,5->{\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$};}
 | 
|  |    406 | \only<4>{\node[state,fill=red] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$};}
 | 
|  |    407 | \only<-4,6->{\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$};}
 | 
|  |    408 | \only<5>{\node[state,fill=red] (Q_3) [right=of Q_2] {$\mbox{Q}_3$};}
 | 
|  |    409 | \only<-5>{\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};}
 | 
|  |    410 | \only<6->{\node[state, accepting,fill=red] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};}
 | 
|  |    411 | 
 | 
|  |    412 | \path[->] (Q_0) edge node [above]  {\alert{$a$}} (Q_1);
 | 
|  |    413 | \path[->] (Q_1) edge node [above]  {\alert{$a$}} (Q_4);
 | 
|  |    414 | \path[->] (Q_4) edge [loop right] node  {\alert{$a, b$}} ();
 | 
|  |    415 | \path[->] (Q_3) edge node [right]  {\alert{$a$}} (Q_4);
 | 
|  |    416 | \path[->] (Q_2) edge node [above]  {\alert{$a$}} (Q_3);
 | 
|  |    417 | \path[->] (Q_1) edge node [right]  {\alert{$b$}} (Q_2);
 | 
|  |    418 | \path[->] (Q_0) edge node [above]  {\alert{$b$}} (Q_2);
 | 
|  |    419 | \path[->] (Q_2) edge [loop left] node  {\alert{$b$}} ();
 | 
|  |    420 | \path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (Q_0);
 | 
|  |    421 | \end{tikzpicture}
 | 
|  |    422 | \end{center}
 | 
| 239 |    423 | 
 | 
| 383 |    424 | \begin{textblock}{10}(4,12)
 | 
|  |    425 | \LARGE{}\phantom{b}
 | 
|  |    426 | \only<-2>{\boldmath\textcolor{gray}{$a$}}\only<3->{\boldmath\alert{$a$}}%
 | 
|  |    427 | \only<-3>{\boldmath\textcolor{gray}{$b$}}\only<4->{\boldmath\alert{$b$}}%
 | 
|  |    428 | \only<-4>{\boldmath\textcolor{gray}{$a$}}\only<5->{\boldmath\alert{$a$}}%
 | 
|  |    429 | \only<-5>{\boldmath\textcolor{gray}{$a$}}\only<6->{\boldmath\alert{$a$}}%
 | 
|  |    430 | \only<-6>{\boldmath\textcolor{gray}{$a$}}\only<7->{\boldmath\alert{$a\quad\Rightarrow \textbf{yes}$}}% 
 | 
| 327 |    431 | \end{textblock}
 | 
|  |    432 |   
 | 
|  |    433 | \end{frame}
 | 
|  |    434 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    435 | 
 | 
|  |    436 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    437 | \begin{frame}[t]
 | 
|  |    438 | \frametitle{DFAs}
 | 
| 239 |    439 | 
 | 
| 327 |    440 | A \alert{\bf deterministic finite automaton} (DFA) consists of
 | 
|  |    441 | 5 things:
 | 
| 239 |    442 | 
 | 
| 327 |    443 | \begin{itemize}
 | 
|  |    444 | \item an alphabet \bl{$\varSigma$}  
 | 
|  |    445 | \item a set of states \bl{$\mbox{Qs}$}
 | 
|  |    446 | \item one of these states is the start state \bl{$\mbox{Q}_0$}
 | 
|  |    447 | \item some states are accepting states \bl{$F$}, and
 | 
|  |    448 | \item there is transition function \bl{$\delta$}\bigskip 
 | 
|  |    449 | 
 | 
|  |    450 | \small
 | 
|  |    451 | which takes a state  and a character as arguments and produces a 
 | 
|  |    452 | new state; this function might not be everywhere defined 
 | 
|  |    453 | \end{itemize}
 | 
|  |    454 | 
 | 
|  |    455 | \begin{center}
 | 
|  |    456 | \bl{$A(\varSigma, \mbox{Qs}, \mbox{Q}_0, F, \delta)$}
 | 
|  |    457 | \end{center}
 | 
| 239 |    458 | 
 | 
|  |    459 | \end{frame}
 | 
| 327 |    460 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    461 | 
 | 
|  |    462 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    463 | \begin{frame}[c]
 | 
|  |    464 | \frametitle{NFAs}  
 | 
| 239 |    465 | 
 | 
| 327 |    466 | \begin{center}
 | 
|  |    467 | \begin{tikzpicture}[>=stealth',very thick, auto,
 | 
|  |    468 |     every state/.style={minimum size=0pt,inner sep=3pt,
 | 
|  |    469 |       draw=blue!50,very thick,fill=blue!20},scale=2]
 | 
|  |    470 | \node[state,initial]  (Q_0)  {$\mbox{Q}_0$};
 | 
|  |    471 | \node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$};
 | 
|  |    472 | \node[state, accepting] (Q_2) [right=of Q_1] {$\mbox{Q}_2$};
 | 
|  |    473 | \path[->] (Q_0) edge [loop above] node  {\alert{$b$}} ();
 | 
|  |    474 | \path[<-] (Q_0) edge node [below]  {\alert{$b$}} (Q_1);
 | 
|  |    475 | \path[->] (Q_0) edge [bend left] node [above]  {\alert{$a$}} (Q_1);
 | 
|  |    476 | \path[->] (Q_0) edge [bend right=45,looseness=1.3] node [below]  {\alert{$a$}} (Q_2);
 | 
|  |    477 | \path[->] (Q_1) edge [loop above] node  {\alert{$a,b$}} ();
 | 
|  |    478 | \path[->] (Q_1) edge node  [above] {\alert{$a$}} (Q_2);
 | 
|  |    479 | \end{tikzpicture}
 | 
|  |    480 | \end{center}
 | 
| 239 |    481 | 
 | 
| 327 |    482 | \end{frame}
 | 
|  |    483 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 239 |    484 | 
 | 
|  |    485 | 
 | 
|  |    486 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    487 | 
 | 
|  |    488 | \begin{frame}[c]
 | 
|  |    489 | \frametitle{Where to go on from here?}
 | 
|  |    490 | 
 | 
|  |    491 | \begin{itemize}
 | 
| 451 |    492 | \item Martin Odersky (EPFL) developed now Scala 3\medskip
 | 
| 239 |    493 | 
 | 
| 452 |    494 | \item I use Ammonite by Haoyi Li\medskip
 | 
| 451 |    495 |   
 | 
| 239 |    496 | \item Elm (\url{http://elm-lang.org})\ldots web applications with style\medskip   
 | 
|  |    497 | 
 | 
|  |    498 | \item Haskell, Ocaml, Standard ML, Scheme, \ldots 
 | 
|  |    499 | \end{itemize}  
 | 
| 452 |    500 | 
 | 
|  |    501 | \begin{textblock}{5}(12,9)
 | 
|  |    502 | \includegraphics[scale=0.15]{../pics/haojili.png} 
 | 
|  |    503 | \end{textblock}  
 | 
| 239 |    504 | \end{frame}
 | 
|  |    505 | 
 | 
|  |    506 | 
 | 
|  |    507 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    508 | 
 | 
|  |    509 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    510 | \begin{frame}[c,fragile]
 | 
|  |    511 | \frametitle{\alert{Questions?}}
 | 
|  |    512 | 
 | 
|  |    513 | {\tiny
 | 
|  |    514 | \begin{verbatim}
 | 
|  |    515 |                                *
 | 
|  |    516 |                               * *
 | 
|  |    517 |                              *   *
 | 
|  |    518 |                             * * * *
 | 
|  |    519 |                            *       *
 | 
|  |    520 |                           * *     * *
 | 
|  |    521 |                          *   *   *   *
 | 
|  |    522 |                         * * * * * * * *
 | 
|  |    523 |                        *               *
 | 
|  |    524 |                       * *             * *
 | 
|  |    525 |                      *   *           *   *
 | 
|  |    526 |                     * * * *         * * * *
 | 
|  |    527 |                    *       *       *       *
 | 
|  |    528 |                   * *     * *     * *     * *
 | 
|  |    529 |                  *   *   *   *   *   *   *   *
 | 
|  |    530 |                 * * * * * * * * * * * * * * * *
 | 
|  |    531 |                *                               *
 | 
|  |    532 |               * *                             * *
 | 
|  |    533 |              *   *                           *   *
 | 
|  |    534 |             * * * *                         * * * *
 | 
|  |    535 |            *       *                       *       *
 | 
|  |    536 |           * *     * *                     * *     * *
 | 
|  |    537 |          *   *   *   *                   *   *   *   *
 | 
|  |    538 |         * * * * * * * *                 * * * * * * * *
 | 
|  |    539 |        *               *               *               *
 | 
|  |    540 |       * *             * *             * *             * *
 | 
|  |    541 |      *   *           *   *           *   *           *   *
 | 
|  |    542 |     * * * *         * * * *         * * * *         * * * *
 | 
|  |    543 |    *       *       *       *       *       *       *       *
 | 
|  |    544 |   * *     * *     * *     * *     * *     * *     * *     * *
 | 
|  |    545 |  *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *
 | 
|  |    546 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 | 
|  |    547 | \end{verbatim}}
 | 
|  |    548 | 
 | 
|  |    549 | 
 | 
|  |    550 | \begin{textblock}{6}(8.5,3.5)
 | 
|  |    551 | \begin{bubble}[5cm]
 | 
|  |    552 | \footnotesize
 | 
|  |    553 | \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 | 
|  |    554 | ++++++++[>+>++++<<-]>++>>
 | 
|  |    555 | +<[-[>>+<<-]+>>]>+[-<<<[-
 | 
|  |    556 | >[+[-]+>++>>>-<<]<[<]>>++
 | 
|  |    557 | ++++[<<+++++>>-]+<<++.[-]
 | 
|  |    558 | <<]>.>+[>>]>+]
 | 
|  |    559 | \end{lstlisting}
 | 
|  |    560 | \end{bubble}
 | 
|  |    561 | \end{textblock}
 | 
|  |    562 |   
 | 
|  |    563 | \end{frame}
 | 
|  |    564 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    565 | 
 | 
| 452 |    566 | \begin{frame}<1-10>[c,fragile]
 | 
|  |    567 | 
 | 
|  |    568 | 
 | 
|  |    569 | \end{frame}  
 | 
|  |    570 | 
 | 
| 328 |    571 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 239 |    572 | 
 | 
|  |    573 | \end{document}
 | 
|  |    574 | 
 | 
|  |    575 | %%% Local Variables:  
 | 
|  |    576 | %%% mode: latex
 | 
|  |    577 | %%% TeX-master: t
 | 
|  |    578 | %%% End: 
 | 
|  |    579 | 
 |