slides/slides02.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 01 Dec 2021 07:51:21 +0000
changeset 416 497f67fd4ae0
parent 365 fc118ee0fce4
child 446 99dcfdf5aed8
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
316
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
     1
% !TEX program = xelatex
360
e45d2890749d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 319
diff changeset
     2
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
     3
%\usepackage{chessboard}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
     4
%\usepackage[LSBC4,T1]{fontenc}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{../slides}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage{../graphics}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\usepackage{../langs}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
     8
\usetikzlibrary{shapes}
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
     9
% \usepackage{../data}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\hfuzz=220pt 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
%\setmonofont[Scale=.88]{Consolas}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
%\newfontfamily{\consolas}{Consolas}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\lstset{language=Scala,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
        style=mystyle,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
        numbersep=0pt,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
        numbers=none,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
        xleftmargin=0mm}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
\newcommand{\bl}[1]{\textcolor{blue}{#1}}     
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
% beamer stuff 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
\renewcommand{\slidecaption}{PEP (Scala) 02, King's College London}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    27
\newcommand{\UParrow}[3]{%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    28
\begin{textblock}{0}(#2,#3)%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    29
\onslide<#1>{%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    30
\begin{tikzpicture}%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    31
\node at (0,0) [single arrow, shape border rotate=90, fill=red,text=red]{a};%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    32
\end{tikzpicture}}%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
    33
\end{textblock}}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
\begin{document}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
\begin{frame}[t]
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
\frametitle{%
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  \begin{tabular}{@ {}c@ {}}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  \\[5mm]
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  \huge PEP Scala (2) 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  \end{tabular}}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  \normalsize
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  \begin{center}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  \begin{tabular}{ll}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    48
    Email:  & christian.urban at kcl.ac.uk\\
360
e45d2890749d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 319
diff changeset
    49
    %Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
316
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
    50
    Slides \& Code: & KEATS\bigskip\\
360
e45d2890749d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 319
diff changeset
    51
    %Office Hours: &  Thursdays 12:00 -- 14:00\\
416
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    52
    %Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    53
    \multicolumn{2}{c}{https://pollev.com/cfltutoratki576}\\
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  \end{tabular}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  \end{center}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
\end{frame}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
416
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    60
\begin{frame}[t,fragile]
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    61
\frametitle{\mbox{}\hspace{40mm}\textbf{???}}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
416
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    63
\begin{textblock}{5}(2,6)
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    64
\includegraphics[scale=0.35]{../pics/commits.png}
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    65
\end{textblock}
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    66
497f67fd4ae0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
    67
\end{frame}
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    68
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    69
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    70
% \begin{frame}[t,fragile]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    71
% \frametitle{For-Comprehensions}
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    72
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    73
% %\small
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    74
% \begin{lstlisting}[language=Scala,numbers=none]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    75
% for (n <- List(1, 2, 3, 4, 5)) yield n * n
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    76
% \end{lstlisting}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    77
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    78
% \begin{textblock}{5}(2,6)
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    79
% \includegraphics[scale=0.3]{../pics/fun.png}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    80
% \end{textblock}  
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    81
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    82
% \begin{textblock}{5}(9,6)
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    83
% \includegraphics[scale=0.3]{../pics/fun.png}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    84
% \end{textblock}  
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    85
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    86
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
    87
% \end{frame}
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    88
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    89
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    90
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    91
\begin{frame}[t]
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    92
\frametitle{For-Comprehensions}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    93
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    94
\begin{center}
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    95
  \begin{tikzpicture}[scale=1,
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    96
                      node/.style={
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    97
                      rectangle,rounded corners=3mm,
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    98
                      very thick,draw=black!50,
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
    99
                      minimum height=18mm, minimum width=20mm,
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   100
                      top color=white,bottom color=black!20}]
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   101
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   102
  \node (A0) at (0.1,0) {\texttt{\textcolor{purple}{\textbf{for}} (\alert<2->{n} <- List(}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   103
  \node (A1) at (2.3,0) {\texttt{\phantom{,}1,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   104
  \node (A2) at (3.2,0) {\texttt{\phantom{,}2,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   105
  \node (A3) at (4.1,0) {\texttt{\phantom{,}3,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   106
  \node (A4) at (5.0,0) {\texttt{\phantom{,}4,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   107
  \node (A5) at (5.9,0) {\texttt{\phantom{))}5))}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   108
  \node (A6) at (8,0) {\texttt{\textcolor{purple}{\textbf{yield}} \alert<2->{n\,*\,n}}};
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   109
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   110
  \onslide<2->{
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   111
  \node (B0) at (1.4,-3) {\texttt{List(}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   112
  \node (B1) at (2.3,-3) {\texttt{\phantom{,}1,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   113
  \node (B2) at (3.6,-3) {\texttt{\phantom{,}4,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   114
  \node (B3) at (4.9,-3) {\texttt{\phantom{,}9,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   115
  \node (B4) at (6.2,-3) {\texttt{\phantom{,}16,}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   116
  \node (B5) at (7.5,-3) {\texttt{\phantom{,}25)}};}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   117
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   118
  \onslide<2->{
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   119
  \draw [->,line width=1mm] (A1.south) -- (B1.north);
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   120
  \draw [->,line width=1mm] (A2.south) -- (B2.north);
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   121
  \draw [->,line width=1mm] (A3.south) -- (B3.north);
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   122
  \draw [->,line width=1mm] (A4.south) -- (B4.north);
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   123
  \draw [->,line width=1mm] (A5.south) -- (B5.north);}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   124
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   125
  \onslide<2->{
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   126
  \node (Q1) at (-0.45,-0.1) {};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   127
  \node (Q2) at (-0.45,-2.8) {};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   128
  \node (Q3) at (-0.45,-2.95) {\alert<2->{\texttt{n\,*\,n:}}};
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   129
  \draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);}
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   130
 \end{tikzpicture}
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   131
\end{center}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   132
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   133
\onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   134
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   135
\end{frame}
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   136
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   137
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   138
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   139
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   140
% \begin{frame}[t]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   141
% \frametitle{For-Comprehensions Again}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   142
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   143
% \begin{center}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   144
%   \begin{tikzpicture}[scale=1,
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   145
%                       node/.style={
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   146
%                       rectangle,rounded corners=3mm,
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   147
%                       very thick,draw=black!50,
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   148
%                       minimum height=18mm, minimum width=20mm,
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   149
%                       top color=white,bottom color=black!20}]
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   150
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   151
%   \node (A0) at (0,0)
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   152
%     {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5))
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   153
%              \textcolor{purple}{\textbf{yield}} n\,*\,n}};
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   154
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   155
%   \node (A1) at (0,-1.5) {\LARGE\textbf{vs}};       
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   156
         
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   157
%   \node (A2) at (0,-3)
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   158
%     {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) println(n)}};
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   159
%  \end{tikzpicture}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   160
% \end{center}\bigskip
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   161
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   162
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   163
% The second version is in case the for \textbf{does not}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   164
% produce any result.
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   165
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   166
% \end{frame}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   167
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   168
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   169
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   170
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   171
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   172
  %\frametitle{Option Type}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   173
  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   174
  Find something below 4 in a list. What do you think Scala answers?\bigskip\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   175
  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   176
  \begin{onlyenv}<1>
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   177
  \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   178
  List(7,2,3,4,5,6).find(_ < 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   179
       
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   180
  List(5,6,7,8,9).find(_ < 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   181
  \end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   182
  \end{onlyenv}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   183
  \begin{onlyenv}<2>
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   184
  \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   185
  List(7,2,3,4,5,6).find(_ < 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   186
  res: Option[Int] = Some(2)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   187
   
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   188
  List(5,6,7,8,9).find(_ < 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   189
  res: Option[Int] = None
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   190
  \end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   191
  \end{onlyenv}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   192
  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   193
  \end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   194
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   195
 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   196
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   197
\begin{frame}[c]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   198
\frametitle{Option Type}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   199
    
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   200
\begin{itemize}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   201
\item if the value is present, you use\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   202
\begin{center}\pcode{Some(value)}\end{center}\bigskip\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   203
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   204
\item if no value is present, you use\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   205
\begin{center}\pcode{None}\end{center}\bigskip\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   206
\end{itemize}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   207
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   208
\small e.g.~\code{Option[Int]}, then \code{Some(42)} and \code{None}\\
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   209
good for error handling      
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   210
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   211
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   212
    
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   213
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   214
\begin{frame}[c,fragile]
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   215
\frametitle{Option Type}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   217
\small   
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   218
\begin{onlyenv}<1>
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   219
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   220
Integer.parseInt("1234")
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   222
// vs.
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   223
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   224
def get_me_an_int(s: String) : Option[Int] = 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   225
 Try(Some(Integer.parseInt(s))).getOrElse(None)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   226
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   227
\end{onlyenv}\bigskip\bigskip\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   228
 
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   229
in the Scala code it is clear from the type I that have to deal 
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   230
with the \pcode{None}-case; no JavaDoc needed
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
  
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   232
\end{frame}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   233
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   234
 
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   236
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   237
\begin{frame}[c,fragile]
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   238
\frametitle{Higher-Order Functions}
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   239
  
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   240
In Scala, functions can take other functions as arguments and can return 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   241
a function as a result.\bigskip\bigskip  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   242
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   243
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   244
List(7,2,3,4,5,6).find(_ < 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   245
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   246
    
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   247
\UParrow{1}{8}{11}    
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   248
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   249
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   250
  
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   251
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   252
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   253
\frametitle{Higher-Order Functions (2)}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   254
  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   255
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   256
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   257
def even(x: Int) : Boolean = x % 2 == 0
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   258
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   259
List(1, 2, 3, 4, 5).filter(even)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   260
  res : List[Int] = List(2, 4)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   261
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   262
List(1, 2, 3, 4, 5).count(even)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   263
  res : Int = 2
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   264
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   265
List(1, 2, 3, 4, 5).find(even)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   266
  res: Option[Int] = Some(2)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   267
\end{lstlisting}
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   268
    
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   269
\end{frame}
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   270
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   271
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   272
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   273
\begin{frame}[c,fragile]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   274
\frametitle{Anonymous Functions}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   275
  
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   276
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   277
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   278
def less4(x: Int) = x < 4
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   279
\end{lstlisting}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   280
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   281
\begin{center}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   282
vs
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   283
\end{center}  
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   284
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   285
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   286
      (x: Int) => x < 4
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   287
\end{lstlisting}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   288
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   289
\end{frame}
1bde878ba6c9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 360
diff changeset
   290
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   291
    
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   292
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   293
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   294
\frametitle{map (lower case)}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   295
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   296
 applies a function to each element of a list (and more)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   297
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   298
\begin{center}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   299
\begin{tikzpicture}[scale=0.9]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   300
                      
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   301
  \node (A0) at (1.2,0) {\texttt{List(\,}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   302
  \node (A1) at (2.0,0) {\texttt{1\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   303
  \node (A2) at (2.9,0) {\texttt{2\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   304
  \node (A3) at (3.8,0) {\texttt{3\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   305
  \node (A4) at (4.7,0) {\texttt{4\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   306
  \node (A5) at (5.6,0) {\texttt{5\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   307
  \node (A6) at (6.5,0) {\texttt{6\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   308
  \node (A7) at (7.4,0) {\texttt{7\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   309
  \node (A8) at (8.3,0) {\texttt{8)}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   310
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   311
  \node (B0) at (1.2,-3) {\texttt{List(\,}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   312
  \node (B1) at (2.0,-3) {\texttt{1\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   313
  \node (B2) at (3.0,-3) {\texttt{4\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   314
  \node (B3) at (4.1,-3) {\texttt{9\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   315
  \node (B4) at (5.2,-3) {\texttt{16\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   316
  \node (B5) at (6.3,-3) {\texttt{25\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   317
  \node (B6) at (7.4,-3) {\texttt{36\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   318
  \node (B7) at (8.4,-3) {\texttt{49\makebox[0mm]{ ,}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   319
  \node (B8) at (9.4,-3) {\texttt{64\makebox[0mm]{ )}}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   320
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   321
  \draw [->,line width=1mm] (A1.south) -- (B1.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   322
  \draw [->,line width=1mm] (A2.south) -- (B2.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   323
  \draw [->,line width=1mm] (A3.south) -- (B3.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   324
  \draw [->,line width=1mm] (A4.south) -- (B4.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   325
  \draw [->,line width=1mm] (A5.south) -- (B5.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   326
  \draw [->,line width=1mm] (A6.south) -- (B6.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   327
  \draw [->,line width=1mm] (A7.south) -- (B7.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   328
  \draw [->,line width=1mm] (A8.south) -- (B8.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   329
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   330
  \node [red] (Q0) at (-0.5,-0.3) {\large\texttt{n}}; 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   331
  \node (Q1) at (-0.5,-0.4) {};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   332
  \node (Q2) at (-0.5,-2.5) {};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   333
  \node [red] (Q3) at (-0.5,-2.65) {\large\texttt{n\,*\,n}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   334
  \draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   335
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   336
  \node [red] at (-1.5,-1.5) {\Large{}\it\textbf{map}};
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   337
 \end{tikzpicture}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   338
\end{center}\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   339
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   340
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   341
List(1,2,3,4,5,6,7,8).map(n => n * n)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   342
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   343
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   344
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   345
  
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   346
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   347
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   348
\frametitle{For-Comprehensions are maps}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   349
  
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   350
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   351
for (n <- List(1,2,3,4,5,6,7,8)) 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   352
  yield n * n
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   353
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   354
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   355
// is just syntactic sugar for
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   356
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   357
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   358
List(1,2,3,4,5,6,7,8).map(n => n * n)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   359
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   360
    
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   361
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   362
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   363
    
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   364
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   365
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   366
\frametitle{Map (upper case)}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   367
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   368
a type, representing a key-value association datastructure\bigskip\bigskip
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   369
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   370
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   371
val ascii = 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   372
     ('a' to 'z').map(c => (c, c.toInt))
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   373
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   374
val ascii_Map = ascii.toMap
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   375
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   376
ascii_Map.get('a')   // -> 97
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   377
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   378
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   379
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   380
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   381
\begin{frame}[c,fragile]
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   382
\frametitle{Pattern Matching}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   383
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   384
\ldots on pairs:\bigskip
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   385
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   386
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   387
def fizz_buzz(n: Int) : String = 
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   388
 (n % 3, n % 5) match {
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   389
   case (0, 0) => "fizz buzz"
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   390
   case (0, _) => "fizz"
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   391
   case (_, 0) => "buzz"
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   392
   case _ => n.toString  
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   393
 }
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   394
\end{lstlisting}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   395
\end{frame}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   396
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   397
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   398
\begin{frame}[c,fragile]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   399
\frametitle{Recursion}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   400
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   401
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   402
def fib(n: Int) : Int = { 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   403
  if (n == 0 || n == 1) 1
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   404
   else fib(n - 1) + fib(n - 2)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   405
}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   406
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   407
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   408
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   409
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   410
\begin{frame}[c,fragile]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   411
\frametitle{Recursion}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   412
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   413
\small
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   414
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-4mm]
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   415
def my_flatten(xs: List[Option[Int]]): List[Int] = 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   416
 xs match {
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   417
   case Nil => Nil 
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   418
   case None :: rest => my_flatten(rest)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   419
   case Some(v) :: rest => v :: my_flatten(rest)
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   420
 }
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   421
\end{lstlisting}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   422
\end{frame}
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   423
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   424
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317
607ceabeeffc updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   425
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   426
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   427
\begin{frame}[c]
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   428
\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   429
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   430
\begin{center}
316
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   431
  \begin{tabular}[t]{@{}l@{}l@{}}
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   432
    \includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   433
    \raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   434
  \end{tabular}     
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   435
\end{center}
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   436
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   437
\begin{center}
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   438
  My Office Hours: Thursdays 12 -- 14\\
8b57dd326a91 updated
Christian Urban <urbanc@in.tum.de>
parents: 205
diff changeset
   439
  And specifically for Scala: Tuesdays 10:45 -- 11:45
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   440
\end{center}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   441
\end{frame}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   442
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   443
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   444
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   445
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   446
% \begin{frame}[t]
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   447
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   448
%   \begin{center}  
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   449
%   \includegraphics[scale=0.3]{../pics/blow.png}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   450
%   \end{center}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   451
  
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   452
%   \begin{textblock}{14}(2,11.4)
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   453
%   \large\bf{}Mind-Blowing Programming Languages:\\ 
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   454
%   Overloading in any language is great but it makes a difference\; \code{10/3}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   455
%   \;or\; \code{10.0/3}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   456
%   \end{textblock}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   457
%   \end{frame}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   458
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   459
    
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   460
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   461
% \begin{frame}[t]
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   462
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   463
%   \begin{center}  
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   464
%   \includegraphics[scale=0.3]{../pics/blow.png}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   465
%   \end{center}
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   466
  
365
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   467
%   \begin{textblock}{14}(2,11.4)
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   468
%   \large\bf{}Mind-Blowing Programming Languages:\\ 
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   469
%   \centering PHP \textcolor{gray}{(7.0)}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   470
%   \end{textblock}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   471
%   \end{frame}
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   472
%   %%%
fc118ee0fce4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 363
diff changeset
   473
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   474
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   475
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   476
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   477
\begin{frame}[c]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   478
\frametitle{Jumping Towers}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   479
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   480
\begin{center}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   481
\begin{tikzpicture}[scale=1.2]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   482
  \draw[line width=1mm,cap=round] (0,0) -- (5,0);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   483
  \draw[line width=1mm,cap=round] (0,1) -- (5,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   484
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   485
  \draw[line width=1mm,cap=round] (0,0) -- (0,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   486
  \node at (0.5,0.5) {\textbf{\Large 3}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   487
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   488
  \draw[line width=1mm,cap=round] (1,0) -- (1,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   489
  \node at (1.5,0.5) {\textbf{\Large 4}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   490
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   491
  \draw[line width=1mm,cap=round] (2,0) -- (2,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   492
  \node at (2.5,0.5) {\textbf{\Large 2}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   493
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   494
  \draw[line width=1mm,cap=round] (3,0) -- (3,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   495
  \node at (3.5,0.5) {\textbf{\Large 0}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   496
  
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   497
  \draw[line width=1mm,cap=round] (4,0) -- (4,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   498
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   499
  \node at (4.5,0.5) {\textbf{\Large 1}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   500
  
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   501
  \draw[line width=1mm,cap=round] (5,0) -- (5,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   502
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   503
  \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (1.5,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   504
  \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (2.5,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   505
  \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (3.5,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   506
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   507
  \draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (3.5,0);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   508
  \draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (4.5,0);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   509
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   510
  \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (4.5,1) to (5.7,1);
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   511
  \node at (5.7, 0.8) {End};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   512
\end{tikzpicture}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   513
\end{center}\bigskip
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   514
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   515
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   516
shortest: 3 $\rightarrow$ 4 $\rightarrow$ End
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   517
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   518
\end{frame}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   519
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   520
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   521
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   522
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   523
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   524
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   525
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   526
\begin{frame}[c]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   527
\frametitle{``Children'' / moves}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   528
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   529
\begin{center}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   530
  \begin{tikzpicture}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   531
    [grow=right,level distance=30mm,child anchor=north,line width=0.5mm]
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   532
  \node {$[3,4,2,0,1]$}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   533
     child {node {$[0,1]$}}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   534
     child {node {$[2,0,1]$}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   535
        child {node {$[1]$} child [level distance=13mm] {node {End}}}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   536
        child {node {$[0,1]$}}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   537
     }
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   538
     child {node {$[4,2,0,1]$\ldots}};
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   539
\end{tikzpicture}
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   540
\end{center}
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   541
\end{frame}
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   542
363
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   543
\begin{frame}<1-10>[t]
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   544
  
e5c1d69cffa4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 362
diff changeset
   545
\end{frame}
319
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   546
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   547
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   548
b84ea52bfd8f updated
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   549
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318
029e2862bb4e updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   550
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   551
\end{document}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   552
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   553
%%% Local Variables:  
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   554
%%% mode: latex
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   555
%%% TeX-master: t
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   556
%%% End: 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   557