\documentclass[dvipsnames,14pt,t,xelatex]{beamer}
\usepackage{../slides}
\usepackage{../graphics}
\usepackage{../langs}
\usepackage{chessboard}
\usepackage[LSBC4,T1]{fontenc}
% \usepackage{../data}
\hfuzz=220pt
%\setmonofont[Scale=.88]{Consolas}
%\newfontfamily{\consolas}{Consolas}
\lstset{language=Scala,
style=mystyle,
numbersep=0pt,
numbers=none,
xleftmargin=0mm}
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
% beamer stuff
\renewcommand{\slidecaption}{PEP (Scala) 02, King's College London}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{%
\begin{tabular}{@ {}c@ {}}
\\[5mm]
\huge PEP Scala (2)
\end{tabular}}
\normalsize
\begin{center}
\begin{tabular}{ll}
Email: & christian.urban at kcl.ac.uk\\
Office: & N7.07 (North Wing, Bush House)\\
Slides \& Code: & KEATS\medskip\\
Scala Office & \\
Hours: & Thursdays 11 -- 13\\
\end{tabular}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t,fragile]
\frametitle{Mea Culpa}
\bigskip
\mbox{\hspace{-4mm}}CW6, Part 3 (deadline 21 December)\bigskip\medskip
\small
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-4mm]
val blchip_portfolio =
List("GOOG", "AAPL", "MSFT", "IBM", "FB",
"YHOO", "AMZN", "BIDU")
val rstate_portfolio =
List("PLD", "PSA", "AMT", "AIV", "AVB",
"BXP", "CBG", "CCI",
"DLR", "EQIX", "EQR", "ESS", "EXR",
"FRT", "GGP", "HCP")
\end{lstlisting}\bigskip
\onslide<2>{The results in the CW are calculated with YHOO and CBG deleted.}
\only<2>{
\begin{textblock}{6}(8.5,6.6)
\begin{tikzpicture}
\node (B0) at (0,0) {};
\node (B1) at (0,0.5) {};
\node (B2) at (1.2,0) {};
\node (B3) at (1.2,0.5) {};
\draw [red,line width=1mm] (B0) -- (B3);
\draw [red,line width=1mm] (B1) -- (B2);
\end{tikzpicture}
\end{textblock}}
\only<2>{
\begin{textblock}{6}(10.5,9.9)
\begin{tikzpicture}
\node (B0) at (0,0) {};
\node (B1) at (0,0.5) {};
\node (B2) at (1.2,0) {};
\node (B3) at (1.2,0.5) {};
\draw [red,line width=1mm] (B0) -- (B3);
\draw [red,line width=1mm] (B1) -- (B2);
\end{tikzpicture}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Mea Culpa 2}
Avoid at all costs, even in comments
\begin{itemize}
\item \texttt{var} \only<2>{$\quad\Rightarrow\;$\texttt{Var}}
\item \texttt{return} \only<2>{$\quad\Rightarrow\;$\texttt{Return}}
\item \texttt{.par}
\item \texttt{ListBuffer}
\item \texttt{mutable}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{For-Comprehensions Again}
\begin{center}
\begin{tikzpicture}[scale=1,
node/.style={
rectangle,rounded corners=3mm,
very thick,draw=black!50,
minimum height=18mm, minimum width=20mm,
top color=white,bottom color=black!20}]
\node (A0) at (0.1,0) {\texttt{\textcolor{purple}{\textbf{for}} (\alert<2->{n} <- List(}};
\node (A1) at (2.3,0) {\texttt{\phantom{,}1,}};
\node (A2) at (3.2,0) {\texttt{\phantom{,}2,}};
\node (A3) at (4.1,0) {\texttt{\phantom{,}3,}};
\node (A4) at (5.0,0) {\texttt{\phantom{,}4,}};
\node (A5) at (5.9,0) {\texttt{\phantom{))}5))}};
\node (A6) at (8,0) {\texttt{\textcolor{purple}{\textbf{yield}} \alert<2->{n\,*\,n}}};
\onslide<2->{
\node (B0) at (1.4,-3) {\texttt{List(}};
\node (B1) at (2.3,-3) {\texttt{\phantom{,}1,}};
\node (B2) at (3.6,-3) {\texttt{\phantom{,}4,}};
\node (B3) at (4.9,-3) {\texttt{\phantom{,}9,}};
\node (B4) at (6.2,-3) {\texttt{\phantom{,}16,}};
\node (B5) at (7.5,-3) {\texttt{\phantom{,}25)}};}
\onslide<2->{
\draw [->,line width=1mm] (A1.south) -- (B1.north);
\draw [->,line width=1mm] (A2.south) -- (B2.north);
\draw [->,line width=1mm] (A3.south) -- (B3.north);
\draw [->,line width=1mm] (A4.south) -- (B4.north);
\draw [->,line width=1mm] (A5.south) -- (B5.north);}
\onslide<2->{
\node (Q1) at (-0.45,-0.1) {};
\node (Q2) at (-0.45,-2.8) {};
\node (Q3) at (-0.45,-2.95) {\alert<2->{\texttt{n\,*\,n:}}};
\draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);}
\end{tikzpicture}
\end{center}
\onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{For-Comprehensions Again}
\begin{center}
\begin{tikzpicture}[scale=1,
node/.style={
rectangle,rounded corners=3mm,
very thick,draw=black!50,
minimum height=18mm, minimum width=20mm,
top color=white,bottom color=black!20}]
\node (A0) at (0,0)
{\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5))
\textcolor{purple}{\textbf{yield}} n\,*\,n}};
\node (A1) at (0,-1.5) {\LARGE\textbf{vs}};
\node (A2) at (0,-3)
{\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) println(n)}};
\end{tikzpicture}
\end{center}\bigskip
The second version is in case the for \textbf{does not}
produce any result.
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Why Scala? No null!}
\begin{itemize}
\item \large {\bf You can avoid \textcolor{blue}{\texttt{null}}}:
\end{itemize}
\begin{textblock}{6}(1,5)
\begin{bubble}[10.5cm]\small
``I call it my billion-dollar mistake. It was the invention of
the null reference in 1965. At that time, I was designing the
first comprehensive type system for references in an object
oriented language (ALGOL W). My goal was to ensure that all use
of references should be absolutely safe, with checking performed
automatically by the compiler. But I couldn't resist the
temptation to put in a null reference, simply because it was so
easy to implement. This has led to innumerable errors,
vulnerabilities, and system crashes, which have probably caused
a billion dollars of pain and damage in the last forty years.''
\hfill Sir Tony (Hoare)
\end{bubble}
\end{textblock}
\begin{textblock}{5}(12.5,1.9)
\includegraphics[scale=0.05]{../pics/hoare.jpg}\\
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\frametitle{\begin{tabular}{c}\\[1cm]\alert{Questions?}\end{tabular}}
\begin{center}
\chessboard[maxfield=g7,
color=blue!50,
linewidth=0.2em,
shortenstart=0.5ex,
shortenend=0.5ex,
markstyle=cross,
markfields={a4, c4, Z3, d3, Z1, d1, a0, c0},
color=red!50,
markfields={f5, e6},
boardfontsize=12pt,labelfontsize=8pt,
setpieces={Ng7, Nb2},showmover=false]
\end{center}
\begin{center}
My Scala Office Hours: Thursdays 11 -- 13
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: