diff -r f88b5cec2e5d -r 1bde878ba6c9 slides/slides02.tex --- a/slides/slides02.tex Sun Nov 15 13:10:43 2020 +0000 +++ b/slides/slides02.tex Tue Nov 17 00:34:55 2020 +0000 @@ -58,105 +58,105 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t,fragile] -\frametitle{For-Comprehensions} +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \begin{frame}[t,fragile] +% \frametitle{For-Comprehensions} -%\small -\begin{lstlisting}[language=Scala,numbers=none] -for (n <- List(1, 2, 3, 4, 5)) yield n * n -\end{lstlisting} +% %\small +% \begin{lstlisting}[language=Scala,numbers=none] +% for (n <- List(1, 2, 3, 4, 5)) yield n * n +% \end{lstlisting} -\begin{textblock}{5}(2,6) -\includegraphics[scale=0.3]{../pics/fun.png} -\end{textblock} +% \begin{textblock}{5}(2,6) +% \includegraphics[scale=0.3]{../pics/fun.png} +% \end{textblock} -\begin{textblock}{5}(9,6) -\includegraphics[scale=0.3]{../pics/fun.png} -\end{textblock} +% \begin{textblock}{5}(9,6) +% \includegraphics[scale=0.3]{../pics/fun.png} +% \end{textblock} -\end{frame} +% \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t] -\frametitle{For-Comprehensions} +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \begin{frame}[t] +% \frametitle{For-Comprehensions} -\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}] +% \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}}}; +% \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->{ +% \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->{ +% \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<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.} +% \onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.} -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \end{frame} +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t] -\frametitle{For-Comprehensions Again} +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \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}] +% \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 (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 (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 +% \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. +% The second version is in case the for \textbf{does not} +% produce any result. -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \end{frame} +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -236,7 +236,7 @@ List(7,2,3,4,5,6).find(_ < 4) \end{lstlisting} -\UParrow{1}{10}{11} +\UParrow{1}{8}{11} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -260,6 +260,26 @@ \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] +\frametitle{Anonymous Functions} + + +\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm] +def less4(x: Int) = x < 4 +\end{lstlisting} + +\begin{center} +vs +\end{center} + +\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm] + (x: Int) => x < 4 +\end{lstlisting} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c,fragile]