--- a/slides/slides02.tex Tue Nov 14 22:19:04 2017 +0000
+++ b/slides/slides02.tex Fri Nov 17 02:13:40 2017 +0000
@@ -34,9 +34,11 @@
\normalsize
\begin{center}
\begin{tabular}{ll}
- Email: & christian.urban at kcl.ac.uk\\
- Office: & S1.27 (1st floor Strand Building)\\
- Slides \& Code: & KEATS
+ 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}
@@ -44,6 +46,152 @@
\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{\begin{tabular}{c}Why Scala?\end{tabular}}
@@ -70,22 +218,13 @@
\end{textblock}
\begin{textblock}{5}(11.8,1)
-\includegraphics[scale=0.20]{hoare.jpg}\\
+%%\includegraphics[scale=0.20]{hoare.jpg}\\
\end{textblock}
\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{\huge\textbf{\texttt{return}}}
-
-\begin{center}\LARGE
-you should never use it
-\end{center}
-
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]