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