56 |
56 |
57 \end{frame} |
57 \end{frame} |
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
59 |
59 |
60 |
60 |
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
61 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
62 \begin{frame}[t,fragile] |
62 % \begin{frame}[t,fragile] |
63 \frametitle{For-Comprehensions} |
63 % \frametitle{For-Comprehensions} |
64 |
64 |
65 %\small |
65 % %\small |
66 \begin{lstlisting}[language=Scala,numbers=none] |
66 % \begin{lstlisting}[language=Scala,numbers=none] |
67 for (n <- List(1, 2, 3, 4, 5)) yield n * n |
67 % for (n <- List(1, 2, 3, 4, 5)) yield n * n |
68 \end{lstlisting} |
68 % \end{lstlisting} |
69 |
69 |
70 \begin{textblock}{5}(2,6) |
70 % \begin{textblock}{5}(2,6) |
71 \includegraphics[scale=0.3]{../pics/fun.png} |
71 % \includegraphics[scale=0.3]{../pics/fun.png} |
72 \end{textblock} |
72 % \end{textblock} |
73 |
73 |
74 \begin{textblock}{5}(9,6) |
74 % \begin{textblock}{5}(9,6) |
75 \includegraphics[scale=0.3]{../pics/fun.png} |
75 % \includegraphics[scale=0.3]{../pics/fun.png} |
76 \end{textblock} |
76 % \end{textblock} |
77 |
77 |
78 |
78 |
79 \end{frame} |
79 % \end{frame} |
80 |
80 |
81 |
81 |
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
82 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
83 \begin{frame}[t] |
83 % \begin{frame}[t] |
84 \frametitle{For-Comprehensions} |
84 % \frametitle{For-Comprehensions} |
85 |
85 |
86 \begin{center} |
86 % \begin{center} |
87 \begin{tikzpicture}[scale=1, |
87 % \begin{tikzpicture}[scale=1, |
88 node/.style={ |
88 % node/.style={ |
89 rectangle,rounded corners=3mm, |
89 % rectangle,rounded corners=3mm, |
90 very thick,draw=black!50, |
90 % very thick,draw=black!50, |
91 minimum height=18mm, minimum width=20mm, |
91 % minimum height=18mm, minimum width=20mm, |
92 top color=white,bottom color=black!20}] |
92 % top color=white,bottom color=black!20}] |
93 |
93 |
94 \node (A0) at (0.1,0) {\texttt{\textcolor{purple}{\textbf{for}} (\alert<2->{n} <- List(}}; |
94 % \node (A0) at (0.1,0) {\texttt{\textcolor{purple}{\textbf{for}} (\alert<2->{n} <- List(}}; |
95 \node (A1) at (2.3,0) {\texttt{\phantom{,}1,}}; |
95 % \node (A1) at (2.3,0) {\texttt{\phantom{,}1,}}; |
96 \node (A2) at (3.2,0) {\texttt{\phantom{,}2,}}; |
96 % \node (A2) at (3.2,0) {\texttt{\phantom{,}2,}}; |
97 \node (A3) at (4.1,0) {\texttt{\phantom{,}3,}}; |
97 % \node (A3) at (4.1,0) {\texttt{\phantom{,}3,}}; |
98 \node (A4) at (5.0,0) {\texttt{\phantom{,}4,}}; |
98 % \node (A4) at (5.0,0) {\texttt{\phantom{,}4,}}; |
99 \node (A5) at (5.9,0) {\texttt{\phantom{))}5))}}; |
99 % \node (A5) at (5.9,0) {\texttt{\phantom{))}5))}}; |
100 \node (A6) at (8,0) {\texttt{\textcolor{purple}{\textbf{yield}} \alert<2->{n\,*\,n}}}; |
100 % \node (A6) at (8,0) {\texttt{\textcolor{purple}{\textbf{yield}} \alert<2->{n\,*\,n}}}; |
101 |
101 |
102 \onslide<2->{ |
102 % \onslide<2->{ |
103 \node (B0) at (1.4,-3) {\texttt{List(}}; |
103 % \node (B0) at (1.4,-3) {\texttt{List(}}; |
104 \node (B1) at (2.3,-3) {\texttt{\phantom{,}1,}}; |
104 % \node (B1) at (2.3,-3) {\texttt{\phantom{,}1,}}; |
105 \node (B2) at (3.6,-3) {\texttt{\phantom{,}4,}}; |
105 % \node (B2) at (3.6,-3) {\texttt{\phantom{,}4,}}; |
106 \node (B3) at (4.9,-3) {\texttt{\phantom{,}9,}}; |
106 % \node (B3) at (4.9,-3) {\texttt{\phantom{,}9,}}; |
107 \node (B4) at (6.2,-3) {\texttt{\phantom{,}16,}}; |
107 % \node (B4) at (6.2,-3) {\texttt{\phantom{,}16,}}; |
108 \node (B5) at (7.5,-3) {\texttt{\phantom{,}25)}};} |
108 % \node (B5) at (7.5,-3) {\texttt{\phantom{,}25)}};} |
109 |
109 |
110 \onslide<2->{ |
110 % \onslide<2->{ |
111 \draw [->,line width=1mm] (A1.south) -- (B1.north); |
111 % \draw [->,line width=1mm] (A1.south) -- (B1.north); |
112 \draw [->,line width=1mm] (A2.south) -- (B2.north); |
112 % \draw [->,line width=1mm] (A2.south) -- (B2.north); |
113 \draw [->,line width=1mm] (A3.south) -- (B3.north); |
113 % \draw [->,line width=1mm] (A3.south) -- (B3.north); |
114 \draw [->,line width=1mm] (A4.south) -- (B4.north); |
114 % \draw [->,line width=1mm] (A4.south) -- (B4.north); |
115 \draw [->,line width=1mm] (A5.south) -- (B5.north);} |
115 % \draw [->,line width=1mm] (A5.south) -- (B5.north);} |
116 |
116 |
117 \onslide<2->{ |
117 % \onslide<2->{ |
118 \node (Q1) at (-0.45,-0.1) {}; |
118 % \node (Q1) at (-0.45,-0.1) {}; |
119 \node (Q2) at (-0.45,-2.8) {}; |
119 % \node (Q2) at (-0.45,-2.8) {}; |
120 \node (Q3) at (-0.45,-2.95) {\alert<2->{\texttt{n\,*\,n:}}}; |
120 % \node (Q3) at (-0.45,-2.95) {\alert<2->{\texttt{n\,*\,n:}}}; |
121 \draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);} |
121 % \draw [->,red,line width=1mm] (Q1.south) -- (Q2.north);} |
122 \end{tikzpicture} |
122 % \end{tikzpicture} |
123 \end{center} |
123 % \end{center} |
124 |
124 |
125 \onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.} |
125 % \onslide<3>{This is for when the for-comprehension\\ \textbf{yields / produces} a result.} |
126 |
126 |
127 \end{frame} |
127 % \end{frame} |
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
128 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
129 |
129 |
130 |
130 |
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
131 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
132 \begin{frame}[t] |
132 % \begin{frame}[t] |
133 \frametitle{For-Comprehensions Again} |
133 % \frametitle{For-Comprehensions Again} |
134 |
134 |
135 \begin{center} |
135 % \begin{center} |
136 \begin{tikzpicture}[scale=1, |
136 % \begin{tikzpicture}[scale=1, |
137 node/.style={ |
137 % node/.style={ |
138 rectangle,rounded corners=3mm, |
138 % rectangle,rounded corners=3mm, |
139 very thick,draw=black!50, |
139 % very thick,draw=black!50, |
140 minimum height=18mm, minimum width=20mm, |
140 % minimum height=18mm, minimum width=20mm, |
141 top color=white,bottom color=black!20}] |
141 % top color=white,bottom color=black!20}] |
142 |
142 |
143 \node (A0) at (0,0) |
143 % \node (A0) at (0,0) |
144 {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) |
144 % {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) |
145 \textcolor{purple}{\textbf{yield}} n\,*\,n}}; |
145 % \textcolor{purple}{\textbf{yield}} n\,*\,n}}; |
146 |
146 |
147 \node (A1) at (0,-1.5) {\LARGE\textbf{vs}}; |
147 % \node (A1) at (0,-1.5) {\LARGE\textbf{vs}}; |
148 |
148 |
149 \node (A2) at (0,-3) |
149 % \node (A2) at (0,-3) |
150 {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) println(n)}}; |
150 % {\texttt{\textcolor{purple}{\textbf{for}} (n <- List(1, 2, 3, 4, 5)) println(n)}}; |
151 \end{tikzpicture} |
151 % \end{tikzpicture} |
152 \end{center}\bigskip |
152 % \end{center}\bigskip |
153 |
153 |
154 |
154 |
155 The second version is in case the for \textbf{does not} |
155 % The second version is in case the for \textbf{does not} |
156 produce any result. |
156 % produce any result. |
157 |
157 |
158 \end{frame} |
158 % \end{frame} |
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
159 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
160 |
160 |
161 |
161 |
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
163 \begin{frame}[c,fragile] |
163 \begin{frame}[c,fragile] |
164 %\frametitle{Option Type} |
164 %\frametitle{Option Type} |