slides/slides02.tex
author Christian Urban <urbanc@in.tum.de>
Fri, 16 Nov 2018 02:06:03 +0000
changeset 204 9b45dd24271b
parent 202 f7bcb27d1940
child 205 940e70378d90
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t,xelatex]{beamer}
151
c5ca7f8e21a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 148
diff changeset
     2
\usepackage{chessboard}
c5ca7f8e21a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 148
diff changeset
     3
\usepackage[LSBC4,T1]{fontenc}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\usepackage{../slides}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{../graphics}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage{../langs}
151
c5ca7f8e21a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 148
diff changeset
     7
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
     8
% \usepackage{../data}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\hfuzz=220pt 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
%\setmonofont[Scale=.88]{Consolas}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
%\newfontfamily{\consolas}{Consolas}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\lstset{language=Scala,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
        style=mystyle,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
        numbersep=0pt,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
        numbers=none,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
        xleftmargin=0mm}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
\newcommand{\bl}[1]{\textcolor{blue}{#1}}     
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
% beamer stuff 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
\renewcommand{\slidecaption}{PEP (Scala) 02, King's College London}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
\begin{document}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
\begin{frame}[t]
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
\frametitle{%
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  \begin{tabular}{@ {}c@ {}}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  \\[5mm]
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  \huge PEP Scala (2) 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  \end{tabular}}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  \normalsize
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  \begin{center}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  \begin{tabular}{ll}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    40
    Email:  & christian.urban at kcl.ac.uk\\
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    41
    Office: & N\liningnums{7.07} (North Wing, Bush House)\\
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    42
    Slides \& Code: & KEATS\medskip\\
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    43
    Office Hours: &  Mondays 12:00 -- 14:00\\
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  \end{tabular}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  \end{center}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
\end{frame}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    51
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    52
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    53
\begin{frame}[c,fragile]
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    54
\frametitle{Scala on Lab Computers}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    55
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    56
\begin{lstlisting}[language={},numbers=none,
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    57
  basicstyle=\ttfamily\small,xleftmargin=-2mm]
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    58
$ /usr/share/scala/bin/scala
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    59
  
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    60
Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    61
Server VM, Java 10.0.1). Type in expressions for
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    62
evaluation. Or try :help.
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    63
202
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    64
scala>
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    65
\end{lstlisting}%$
f7bcb27d1940 updated
Christian Urban <urbanc@in.tum.de>
parents: 151
diff changeset
    66
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    67
\end{frame}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    68
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    69
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    70
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    71
\begin{frame}[c]
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    72
\frametitle{Assignments}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    73
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    74
Don't change anything with the templates!\bigskip
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    75
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    76
Avoid at all costs:
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    77
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    78
\begin{itemize}
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    79
\item \texttt{var} 
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    80
\item \texttt{return} 
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
    81
\item \texttt{ListBuffer}
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    82
\item \texttt{mutable}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    83
\item \texttt{.par}  
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    84
\end{itemize}\pause\bigskip
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
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    87
\mbox{}\hfill\textit{``Scala --- \underline{S}lowly \underline{c}ompiled 
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    88
\underline{a}cademic \underline{la}nguage''}\smallskip\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    89
\mbox{}\hfill\textit{ --- a joke(?) found on Twitter}\bigskip
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    90
\end{frame}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    91
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    92
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    93
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    94
\begin{frame}[t]
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    95
\frametitle{Email: Hate 'val'}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    96
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    97
\mbox{}\\[-25mm]\mbox{}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    98
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    99
\begin{center}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   100
  \begin{bubble}[10.5cm]
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   101
  Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   102
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   103
  Hello Mr Urban,\medskip\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   104
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   105
  I just wanted to ask, how are we suppose to work
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   106
  with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   107
  this rule active at all? I’ve spent 4 hours not thinking on the
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   108
  coursework, but how to bypass this annoying rule. What’s the whole
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   109
  point of all these coursework, when we can’t use everything Scala
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   110
  gives us?!?\medskip\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   111
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   112
  Regards.\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   113
  \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   114
  \end{bubble}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   115
\end{center}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   116
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   117
\end{frame}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   118
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   119
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   120
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   121
\def\firstcircle{(0,0) circle (1.4cm)}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   122
\def\secondcircle{(0:2cm) circle (1.4cm)}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   123
\colorlet{circle edge}{blue!50}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   124
\colorlet{circle area}{blue!20}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   125
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   126
\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   127
    outline/.style={draw=circle edge, thick}}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   128
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   129
\begin{frame}[c,fragile]
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   130
\frametitle{Par: Intersections}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   131
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   132
\begin{textblock}{6}(1,2)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   133
\begin{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   134
  \draw[outline] \firstcircle node {$A$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   135
  \node[anchor=south] at (current bounding box.north)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   136
    {$A = \{1,2,3,\ldots,1000\}$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   137
\end{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   138
\end{textblock}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   139
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   140
\begin{textblock}{6}(8,2)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   141
\begin{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   142
  \draw[outline] \secondcircle node {$B$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   143
  \node[anchor=south] at (current bounding box.north)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   144
    {$B = \{1,5,9,13,\ldots,997\}$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   145
\end{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   146
\end{textblock}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   147
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   148
\begin{textblock}{6}(3.3,9)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   149
\begin{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   150
    \begin{scope}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   151
        \clip \firstcircle;
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   152
        \fill[filled] \secondcircle;
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   153
    \end{scope}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   154
    \draw[outline] \firstcircle node {$A$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   155
    \draw[outline] \secondcircle node {$B$};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   156
    \node[anchor=north] at (current bounding box.south)
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   157
    {How many elements are in $A \cap B$?};
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   158
\end{tikzpicture}
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   159
\end{textblock}  
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   160
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   161
\end{frame}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   162
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   165
\begin{frame}[t]
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   166
\frametitle{For-Comprehensions Again}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   167
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   168
\begin{center}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   169
  \begin{tikzpicture}[scale=1,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   170
                      node/.style={
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   171
                      rectangle,rounded corners=3mm,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   172
                      very thick,draw=black!50,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   173
                      minimum height=18mm, minimum width=20mm,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   174
                      top color=white,bottom color=black!20}]
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   175
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   176
  \node (A0) at (0.1,0) {\texttt{\textcolor{purple}{\textbf{for}} (\alert<2->{n} <- List(}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   177
  \node (A1) at (2.3,0) {\texttt{\phantom{,}1,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   178
  \node (A2) at (3.2,0) {\texttt{\phantom{,}2,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   179
  \node (A3) at (4.1,0) {\texttt{\phantom{,}3,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   180
  \node (A4) at (5.0,0) {\texttt{\phantom{,}4,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   181
  \node (A5) at (5.9,0) {\texttt{\phantom{))}5))}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   182
  \node (A6) at (8,0) {\texttt{\textcolor{purple}{\textbf{yield}} \alert<2->{n\,*\,n}}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   183
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   184
  \onslide<2->{
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   185
  \node (B0) at (1.4,-3) {\texttt{List(}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   186
  \node (B1) at (2.3,-3) {\texttt{\phantom{,}1,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   187
  \node (B2) at (3.6,-3) {\texttt{\phantom{,}4,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   188
  \node (B3) at (4.9,-3) {\texttt{\phantom{,}9,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   189
  \node (B4) at (6.2,-3) {\texttt{\phantom{,}16,}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   190
  \node (B5) at (7.5,-3) {\texttt{\phantom{,}25)}};}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   191
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   192
  \onslide<2->{
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   193
  \draw [->,line width=1mm] (A1.south) -- (B1.north);
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   194
  \draw [->,line width=1mm] (A2.south) -- (B2.north);
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   195
  \draw [->,line width=1mm] (A3.south) -- (B3.north);
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   196
  \draw [->,line width=1mm] (A4.south) -- (B4.north);
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   197
  \draw [->,line width=1mm] (A5.south) -- (B5.north);}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   198
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   199
  \onslide<2->{
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   200
  \node (Q1) at (-0.45,-0.1) {};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   201
  \node (Q2) at (-0.45,-2.8) {};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   202
  \node (Q3) at (-0.45,-2.95) {\alert<2->{\texttt{n\,*\,n:}}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   203
  \draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   204
 \end{tikzpicture}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   205
\end{center}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   206
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   207
\onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   208
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   209
\end{frame}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   210
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   211
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   212
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   213
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   214
\begin{frame}[t]
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   215
\frametitle{For-Comprehensions Again}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   216
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   217
\begin{center}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   218
  \begin{tikzpicture}[scale=1,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   219
                      node/.style={
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   220
                      rectangle,rounded corners=3mm,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   221
                      very thick,draw=black!50,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   222
                      minimum height=18mm, minimum width=20mm,
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   223
                      top color=white,bottom color=black!20}]
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   224
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   225
  \node (A0) at (0,0)
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   226
    {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5))
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   227
             \textcolor{purple}{\textbf{yield}} n\,*\,n}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   228
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   229
  \node (A1) at (0,-1.5) {\LARGE\textbf{vs}};       
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   230
         
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   231
  \node (A2) at (0,-3)
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   232
    {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) println(n)}};
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   233
 \end{tikzpicture}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   234
\end{center}\bigskip
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   235
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   236
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   237
The second version is in case the for \textbf{does not}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   238
produce any result.
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   239
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   240
\end{frame}
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   241
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   242
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   243
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   244
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   245
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
\begin{frame}[t]
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   247
\frametitle{Why Scala? No null!}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
\begin{itemize}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
\item \large {\bf You can avoid \textcolor{blue}{\texttt{null}}}:
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
\end{itemize}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
\begin{textblock}{6}(1,5)
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
  \begin{bubble}[10.5cm]\small
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
      ``I call it my billion-dollar mistake. It was the invention of
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
      the null reference in 1965. At that time, I was designing the
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   259
      first comprehensive type system for references in an object
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   260
      oriented language (ALGOL W). My goal was to ensure that all use
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   261
      of references should be absolutely safe, with checking performed
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
      automatically by the compiler. But I couldn't resist the
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
      temptation to put in a null reference, simply because it was so
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
      easy to implement. This has led to innumerable errors,
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
      vulnerabilities, and system crashes, which have probably caused
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   266
      a billion dollars of pain and damage in the last forty years.''
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   267
      \hfill Sir Tony (Hoare)
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   268
\end{bubble}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   269
\end{textblock}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   270
  
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   271
\begin{textblock}{5}(12.5,1.9)
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   272
\includegraphics[scale=0.05]{../pics/hoare.jpg}\\
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   273
\end{textblock}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   274
  
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   275
\end{frame}
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   276
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   277
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   278
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   279
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   280
\begin{frame}[c,fragile]
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   281
\frametitle{\begin{tabular}{c}\\[1cm]\alert{Questions?}\end{tabular}}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   282
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   283
\begin{center}
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   284
\chessboard[maxfield=g7,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   285
            color=blue!50,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   286
            linewidth=0.2em,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   287
            shortenstart=0.5ex,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   288
            shortenend=0.5ex,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   289
            markstyle=cross,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   290
            markfields={a4, c4, Z3, d3, Z1, d1, a0, c0},
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   291
            color=red!50,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   292
            markfields={f5, e6},
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   293
            boardfontsize=12pt,labelfontsize=8pt,
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   294
            setpieces={Ng7, Nb2},showmover=false]
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   295
\end{center}
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   296
            
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   297
\begin{center}
204
9b45dd24271b updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   298
My Office Hours: Mondays 12 -- 14
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   299
\end{center}
66
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   300
\end{frame}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   301
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   302
\end{document}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   303
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   304
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   305
\end{document}
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   306
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   307
%%% Local Variables:  
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   308
%%% mode: latex
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   309
%%% TeX-master: t
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
%%% End: 
3506b681c191 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   311