308
|
1 |
% !TEX program = xelatex
|
352
|
2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
|
22
|
3 |
\usepackage{../slides}
|
32
|
4 |
\usepackage{../graphics}
|
22
|
5 |
\usepackage{../langs}
|
|
6 |
%\usepackage{../data}
|
309
|
7 |
\usetikzlibrary{shapes}
|
22
|
8 |
|
|
9 |
\hfuzz=220pt
|
|
10 |
|
|
11 |
%\setmonofont[Scale=.88]{Consolas}
|
|
12 |
%\newfontfamily{\consolas}{Consolas}
|
|
13 |
|
|
14 |
\lstset{language=Scala,
|
|
15 |
style=mystyle,
|
|
16 |
numbersep=0pt,
|
|
17 |
numbers=none,
|
|
18 |
xleftmargin=0mm}
|
|
19 |
|
353
|
20 |
|
|
21 |
\colorlet{punct}{red!60!black}
|
|
22 |
\definecolor{background}{HTML}{EEEEEE}
|
|
23 |
\definecolor{delim}{RGB}{20,105,176}
|
|
24 |
\colorlet{numb}{magenta!60!black}
|
|
25 |
|
|
26 |
\lstdefinelanguage{json}{
|
|
27 |
basicstyle=\normalfont\ttfamily,
|
|
28 |
numbers=left,
|
|
29 |
numberstyle=\scriptsize,
|
|
30 |
stepnumber=1,
|
|
31 |
%numbersep=8pt,
|
|
32 |
showstringspaces=false,
|
|
33 |
breaklines=true,
|
|
34 |
%frame=lines,
|
|
35 |
%backgroundcolor=\color{background},
|
|
36 |
literate=
|
|
37 |
*{0}{{{\color{numb}0}}}{1}
|
|
38 |
{1}{{{\color{numb}1}}}{1}
|
|
39 |
{2}{{{\color{numb}2}}}{1}
|
|
40 |
{3}{{{\color{numb}3}}}{1}
|
|
41 |
{4}{{{\color{numb}4}}}{1}
|
|
42 |
{5}{{{\color{numb}5}}}{1}
|
|
43 |
{6}{{{\color{numb}6}}}{1}
|
|
44 |
{7}{{{\color{numb}7}}}{1}
|
|
45 |
{8}{{{\color{numb}8}}}{1}
|
|
46 |
{9}{{{\color{numb}9}}}{1}
|
|
47 |
{:}{{{\color{punct}{:}}}}{1}
|
|
48 |
{,}{{{\color{punct}{,}}}}{1}
|
|
49 |
{\{}{{{\color{delim}{\{}}}}{1}
|
|
50 |
{\}}{{{\color{delim}{\}}}}}{1}
|
|
51 |
{[}{{{\color{delim}{[}}}}{1}
|
|
52 |
{]}{{{\color{delim}{]}}}}{1},
|
|
53 |
}
|
|
54 |
|
309
|
55 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
|
|
56 |
|
|
57 |
\newcommand{\RIGHTarrow}[3]{%
|
|
58 |
\begin{textblock}{0}(#2,#3)%
|
|
59 |
\onslide<#1>{%
|
|
60 |
\begin{tikzpicture}%
|
|
61 |
\node at (0,0) [single arrow, shape border rotate=0, fill=red,text=red]{a};%
|
|
62 |
\end{tikzpicture}}%
|
|
63 |
\end{textblock}}
|
|
64 |
\newcommand{\LEFTarrow}[3]{%
|
|
65 |
\begin{textblock}{0}(#2,#3)%
|
|
66 |
\onslide<#1>{%
|
|
67 |
\begin{tikzpicture}%
|
|
68 |
\node at (0,0) [single arrow, shape border rotate=180, fill=red,text=red]{a};%
|
|
69 |
\end{tikzpicture}}%
|
|
70 |
\end{textblock}}
|
|
71 |
\newcommand{\DOWNarrow}[3]{%
|
|
72 |
\begin{textblock}{0}(#2,#3)%
|
|
73 |
\onslide<#1>{%
|
|
74 |
\begin{tikzpicture}%
|
|
75 |
\node at (0,0) [single arrow, shape border rotate=270, fill=red,text=red]{a};%
|
|
76 |
\end{tikzpicture}}%
|
|
77 |
\end{textblock}}
|
22
|
78 |
|
|
79 |
% beamer stuff
|
195
|
80 |
\renewcommand{\slidecaption}{PEP (Scala) \liningnums{01}, King's College London}
|
22
|
81 |
|
334
|
82 |
% https://insights.stackoverflow.com/survey/2019#technology-most-loved-dreaded-and-wanted
|
|
83 |
|
|
84 |
% processors in the future / Ahmdahl law
|
|
85 |
% https://www.youtube.com/watch?v=_9mzmvhwMqw
|
|
86 |
|
352
|
87 |
\setbeamertemplate{itemize items}{$\bullet$}
|
|
88 |
\setbeamertemplate{itemize subitem}{$\bullet$}
|
|
89 |
\setbeamertemplate{itemize subsubitem}{$\bullet$}
|
|
90 |
|
|
91 |
\usepackage{tcolorbox}
|
|
92 |
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
|
|
93 |
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
|
|
94 |
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
|
22
|
95 |
|
|
96 |
\begin{document}
|
|
97 |
|
|
98 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
99 |
\begin{frame}[t]
|
|
100 |
\frametitle{%
|
|
101 |
\begin{tabular}{@ {}c@ {}}
|
|
102 |
\\[5mm]
|
199
|
103 |
\hspace{7mm}\huge PEP Scala (\liningnums{1})
|
22
|
104 |
\end{tabular}}
|
|
105 |
|
|
106 |
\normalsize
|
|
107 |
\begin{center}
|
|
108 |
\begin{tabular}{ll}
|
137
|
109 |
Email: & christian.urban at kcl.ac.uk\\
|
353
|
110 |
%Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
|
309
|
111 |
Slides \& Code: & KEATS\bigskip\\
|
353
|
112 |
%Office Hours: & Thursdays 12:00 -- 14:00\\
|
|
113 |
%Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\
|
22
|
114 |
\end{tabular}
|
|
115 |
\end{center}
|
|
116 |
|
199
|
117 |
%\tiny
|
|
118 |
%developed since 2004 bv Martin Odersky
|
|
119 |
%picture about assignments
|
|
120 |
|
|
121 |
\begin{textblock}{6}(0.5,0.5)
|
|
122 |
\includegraphics[scale=0.035]{../pics/assign.jpg}\\[-1mm]
|
|
123 |
\end{textblock}
|
22
|
124 |
|
|
125 |
\end{frame}
|
|
126 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
127 |
|
|
128 |
|
|
129 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
130 |
\begin{frame}[c]
|
|
131 |
\frametitle{Why Scala?}
|
|
132 |
|
352
|
133 |
\begin{textblock}{6}(3,3)
|
22
|
134 |
\begin{tabular}{l}
|
|
135 |
\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
|
|
136 |
\includegraphics[scale=0.30]{../pics/linked.png}\\
|
141
|
137 |
\includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
|
22
|
138 |
\mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
|
|
139 |
\includegraphics[scale=0.30]{../pics/suisse.png}\\
|
23
|
140 |
{\large\bf ...}
|
|
141 |
\end{tabular}
|
|
142 |
\end{textblock}
|
|
143 |
|
352
|
144 |
\begin{textblock}{6}(9,3)
|
23
|
145 |
\begin{tabular}{l}
|
22
|
146 |
\includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
|
|
147 |
\includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
|
|
148 |
\includegraphics[scale=0.30]{../pics/foursquare.png}\\
|
|
149 |
\includegraphics[scale=0.30]{../pics/hsbc.png}\\
|
|
150 |
{\large\bf ...}
|
|
151 |
\end{tabular}
|
|
152 |
\end{textblock}
|
|
153 |
|
199
|
154 |
|
352
|
155 |
\begin{textblock}{12}(2,11)
|
|
156 |
\footnotesize
|
|
157 |
\begin{mybox3}{A former student working now at Quantexa:}\it
|
|
158 |
``I am a former student. I graduated last year. I got my dream job
|
|
159 |
as a backend Scala developer. Most of the Scala I know is from PEP
|
|
160 |
2018/19. My interviewers said they expect code of a lesser quality
|
|
161 |
even from people with one year of experience.''
|
|
162 |
\end{mybox3}
|
|
163 |
\end{textblock}
|
199
|
164 |
|
22
|
165 |
\end{frame}
|
|
166 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
167 |
|
352
|
168 |
%\begin{textblock}{6}(2,12)
|
|
169 |
%\begin{bubble}[9.4cm]
|
|
170 |
% \small
|
|
171 |
% developed since 2004 by Martin Odersky
|
|
172 |
% (he was behind Generic Java which was included in Java 5
|
|
173 |
% \ldots I am using Scala since maybe 2008?)
|
|
174 |
%\end{bubble}
|
|
175 |
%\end{textblock}
|
23
|
176 |
|
|
177 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
178 |
\begin{frame}[c]
|
|
179 |
\frametitle{Why Scala?}
|
|
180 |
|
|
181 |
\begin{itemize}
|
34
|
182 |
\item compiles to the JVM\\
|
|
183 |
\textcolor{gray}{(also JavaScript, native X86 in the works)}\medskip
|
32
|
184 |
\item integrates seamlessly with Java\medskip
|
352
|
185 |
\item combines \underline{\bf functional} and {\bf object-oriented} programming\medskip
|
|
186 |
|
|
187 |
\item no pointers, no null
|
|
188 |
%\item it is a bit on the ``theory'' / ``mathematical'' side\\
|
|
189 |
% \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
|
34
|
190 |
|
33
|
191 |
\item often one can write very concise and elegant code
|
|
192 |
\end{itemize}\bigskip\medskip
|
|
193 |
|
308
|
194 |
%\small
|
|
195 |
%alternatives:\\
|
|
196 |
%Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots
|
23
|
197 |
|
|
198 |
\end{frame}
|
22
|
199 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
23
|
200 |
|
|
201 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
308
|
202 |
\begin{frame}[t]
|
32
|
203 |
\frametitle{Java vs Scala}
|
|
204 |
|
308
|
205 |
{\lstset{language=java,numbers=right}\fontsize{12}{12}\selectfont
|
32
|
206 |
\texttt{\lstinputlisting{Point.java}}}
|
|
207 |
|
308
|
208 |
\rule{11cm}{0.3mm}\\[-3mm]
|
33
|
209 |
|
32
|
210 |
{\lstset{language=scala}\fontsize{12}{12}\selectfont
|
|
211 |
\texttt{\lstinputlisting{Point.scala}}}
|
|
212 |
|
|
213 |
\begin{textblock}{6}(13,3)
|
|
214 |
\textbf{\large Java}
|
33
|
215 |
\end{textblock}
|
|
216 |
|
308
|
217 |
\begin{textblock}{6}(13,14.3)
|
32
|
218 |
\textbf{\large Scala}
|
|
219 |
\end{textblock}
|
|
220 |
|
|
221 |
\end{frame}
|
|
222 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
223 |
|
174
|
224 |
|
|
225 |
|
|
226 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
227 |
\begin{frame}[c]
|
137
|
228 |
\frametitle{First Steps: Scala Tools}
|
32
|
229 |
|
33
|
230 |
\begin{itemize}
|
308
|
231 |
\item contains a REPL
|
200
|
232 |
\item I use VS Code and a Scala extension (M'place)
|
199
|
233 |
\begin{center}
|
|
234 |
\includegraphics[scale=0.10]{../pics/vscode.png}\\[-10mm]\mbox{}
|
|
235 |
\end{center}\bigskip
|
|
236 |
|
33
|
237 |
\item there is a plugin for Eclipse (called Scala IDE)\medskip
|
137
|
238 |
\item there is also a plugin for IntelliJ\medskip
|
33
|
239 |
\end{itemize}
|
|
240 |
|
|
241 |
\end{frame}
|
137
|
242 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
243 |
|
|
244 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
353
|
245 |
\begin{frame}[c, fragile]
|
|
246 |
|
|
247 |
\small
|
|
248 |
My personal keboard shortcut for VS Code\\
|
|
249 |
(in keybindings.json)\bigskip
|
|
250 |
|
360
|
251 |
\footnotesize
|
|
252 |
\begin{lstlisting}[language=json,numbers=none,xrightmargin=-4cm]
|
353
|
253 |
[
|
|
254 |
{
|
|
255 |
"key": "ctrl+enter",
|
|
256 |
"command": "workbench.action.terminal.runSelectedText",
|
|
257 |
"when": "editorTextFocus && editorHasSelection"
|
|
258 |
}
|
|
259 |
]
|
|
260 |
\end{lstlisting}
|
|
261 |
|
|
262 |
|
|
263 |
\end{frame}
|
|
264 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
265 |
|
|
266 |
|
|
267 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
309
|
268 |
\begin{frame}[t]
|
|
269 |
\frametitle{Why Scala?}
|
|
270 |
|
|
271 |
\onslide<2->{%
|
|
272 |
\begin{center}
|
|
273 |
{\large\bf{}Money?}\bigskip\\
|
|
274 |
\begin{tabular}{@{}c@{}c@{}}
|
|
275 |
\includegraphics[scale=0.2]{../pics/salary1.png} &
|
|
276 |
\includegraphics[scale=0.2]{../pics/salary2.png}\\
|
|
277 |
\multicolumn{2}{r@{}}{\footnotesize$^*$ source: Stackoverflow Developer Survey, 2019}
|
|
278 |
\end{tabular}
|
|
279 |
\end{center}
|
353
|
280 |
\RIGHTarrow{2}{2.0}{6.3}
|
314
|
281 |
\DOWNarrow{2}{10.1}{4.4}
|
309
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
\small
|
|
286 |
Elm, Rust, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots
|
|
287 |
|
|
288 |
\only<3>{
|
|
289 |
\begin{textblock}{6}(3.3,6.2)
|
|
290 |
\begin{bubble}[6.5cm]
|
|
291 |
\bf\huge\textcolor{RoyalBlue}{Functional Programming!}
|
|
292 |
\end{bubble}
|
|
293 |
\end{textblock}}
|
|
294 |
|
|
295 |
\end{frame}
|
|
296 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
297 |
|
|
298 |
|
|
299 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
137
|
300 |
\begin{frame}[c]
|
309
|
301 |
\frametitle{\begin{tabular}{c}\\[2mm]
|
|
302 |
Why Functional\\[-2mm] Programming?\end{tabular}
|
137
|
303 |
}
|
|
304 |
|
|
305 |
%
|
|
306 |
\mbox{}\\[3.5cm]
|
|
307 |
\small
|
309
|
308 |
Elm, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots
|
137
|
309 |
|
309
|
310 |
\only<2>{
|
|
311 |
\begin{textblock}{6}(1.3,6.2)
|
137
|
312 |
\begin{bubble}[10cm]
|
|
313 |
\normalsize``If you want to see which features will be in mainstream programming
|
|
314 |
languages tomorrow, then take a look at functional programming
|
|
315 |
languages today.''\medskip\small\\
|
|
316 |
\hfill{}---Simon Peyton Jones (works at Microsoft)\\
|
|
317 |
\hfill{}main developer of the Glasgow Haskell Compiler
|
|
318 |
\end{bubble}
|
|
319 |
\end{textblock}}
|
|
320 |
|
309
|
321 |
\only<3>{
|
200
|
322 |
\begin{textblock}{6}(5,5.8)
|
|
323 |
\hspace{2mm}\includegraphics[scale=0.06]{../pics/assign.jpg}\\[-1mm]
|
309
|
324 |
\Large\alert{\hspace{5mm}\textbf{Immutability}}
|
200
|
325 |
\end{textblock}}
|
|
326 |
|
|
327 |
|
137
|
328 |
\end{frame}
|
|
329 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
330 |
|
200
|
331 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
309
|
332 |
\begin{frame}[c]
|
|
333 |
|
|
334 |
\begin{center}
|
|
335 |
\includegraphics[scale=0.4]{../pics/pure.png}
|
|
336 |
\end{center}
|
|
337 |
|
|
338 |
\begin{textblock}{6}(9,14)
|
|
339 |
\tiny$^*$ from ``What pure functional programming is all about?''
|
|
340 |
\end{textblock}
|
|
341 |
\end{frame}
|
|
342 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
343 |
|
|
344 |
|
|
345 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
200
|
346 |
\begin{frame}[c, fragile]
|
|
347 |
|
|
348 |
{\Large Why bother? or\smallskip\\\hfill What is wrong with this?}\bigskip\bigskip
|
|
349 |
|
|
350 |
|
|
351 |
\begin{lstlisting}[language=C,numbers=none]
|
|
352 |
for (int i = 10; i < 20; i++) {
|
|
353 |
|
|
354 |
//...Do something interesting
|
|
355 |
// with i...
|
|
356 |
|
|
357 |
}
|
|
358 |
\end{lstlisting}
|
|
359 |
|
|
360 |
|
|
361 |
\end{frame}
|
|
362 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
363 |
|
|
364 |
|
|
365 |
|
137
|
366 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
367 |
\begin{frame}[c]
|
|
368 |
\mbox{}\\[-21mm]\mbox{}
|
|
369 |
|
|
370 |
\begin{center}
|
|
371 |
\begin{tikzpicture}[scale=1,
|
|
372 |
node/.style={
|
|
373 |
rectangle,rounded corners=3mm,
|
|
374 |
very thick,draw=black!50,
|
|
375 |
minimum height=18mm, minimum width=20mm,
|
|
376 |
top color=white,bottom color=black!20}]
|
|
377 |
|
|
378 |
\onslide<1-10>{
|
|
379 |
\node (A) at (0,0) [node]
|
|
380 |
{\mbox{\includegraphics[scale=0.15]{../pics/cplus2.jpg}}};
|
|
381 |
\node [above right] at (A.north west) {1986};}
|
|
382 |
|
|
383 |
\onslide<2->{
|
|
384 |
\node (B) at (3.5,0) [node]
|
|
385 |
{\mbox{\includegraphics[scale=0.15]{../pics/robotron.jpg}}};
|
|
386 |
\node [above right] at (B.north west) {1988, C};
|
|
387 |
\draw [->,line width=4mm] (A) -- (B);}
|
|
388 |
|
|
389 |
\onslide<3->{
|
|
390 |
\node (C0) at (6.3,0) {};
|
|
391 |
\node (C) at (8,0) [node]
|
|
392 |
{\mbox{\includegraphics[scale=0.15]{../pics/sun.jpg}}};
|
|
393 |
\node [above right] at (C.north west) {1992, {\small Linux}};
|
|
394 |
\draw [->,line width=4mm] (B) -- (C0);
|
|
395 |
\draw [->,line width=4mm] (C0) -- (C);}
|
|
396 |
|
|
397 |
\onslide<4->{
|
|
398 |
\node (D) at (8,-3.3) [node]
|
|
399 |
{\mbox{\includegraphics[scale=0.2]{../pics/gateway.jpg}}};
|
|
400 |
\draw [->,line width=4mm] (C) -- (D);
|
|
401 |
\node [below right] at (D.south west) {1996};}
|
|
402 |
|
|
403 |
\onslide<5->{
|
|
404 |
\node (E) at (4,-3.3) [node]
|
|
405 |
{\mbox{\includegraphics[scale=0.1]{../pics/appleg4.jpg}}};
|
|
406 |
\draw [->,line width=4mm] (D) -- (E);
|
|
407 |
\node [above right] at (E.north west) {2000};}
|
|
408 |
|
|
409 |
\onslide<6->{
|
|
410 |
\node (F0) at (1.5,-3.3) {};
|
|
411 |
\node (F1) at (1,-3.3) {};
|
|
412 |
\node (F) at (-0.9,-3.3) [node]
|
|
413 |
{\mbox{\includegraphics[scale=0.3]{../pics/appleair.png}}};
|
|
414 |
\draw [->,line width=4mm] (E) -- (F0);
|
|
415 |
\draw [->,line width=4mm] (F1) -- (F);
|
|
416 |
\node [above right] at (F.north west) {2012?};}
|
|
417 |
|
|
418 |
\onslide<7->{
|
|
419 |
\node (G) at (-0.9,-6.3) [node]
|
|
420 |
{\mbox{\includegraphics[scale=0.02]{../pics/applepro.jpg}}};
|
|
421 |
\draw [->,line width=4mm] (F) -- (G);
|
|
422 |
\node [right] at (G.west) {\hspace{22mm}2017};}
|
|
423 |
|
|
424 |
\end{tikzpicture}
|
|
425 |
\end{center}
|
|
426 |
|
|
427 |
|
|
428 |
\only<1>{%
|
|
429 |
\begin{textblock}{10}(2.5,5)
|
|
430 |
\includegraphics[scale=0.26]{../pics/cplus1.jpg}\\
|
|
431 |
\footnotesize 64K RAM, no HD, no monitor, lots of cables
|
|
432 |
\end{textblock}
|
|
433 |
\begin{textblock}{6}(10.9,4.5)
|
|
434 |
\includegraphics[scale=0.09]{../pics/mand1.png}
|
|
435 |
\includegraphics[scale=0.09]{../pics/mand2.png}
|
|
436 |
\end{textblock}
|
|
437 |
\begin{textblock}{6}(10.8,2.2)
|
|
438 |
\huge\bf 3 days
|
|
439 |
\end{textblock}
|
|
440 |
}
|
|
441 |
\only<8->{%
|
|
442 |
\begin{textblock}{8}(5.8,11.6)
|
|
443 |
\large\bf
|
|
444 |
\begin{tabular}{l@{}l}
|
|
445 |
1986:\, & no Internet\\
|
|
446 |
& no Amazon\\
|
|
447 |
& no FB, no mobiles,\ldots\\
|
|
448 |
\end{tabular}
|
|
449 |
\end{textblock}
|
|
450 |
}
|
|
451 |
\only<9>{
|
|
452 |
\begin{textblock}{1}(3,3)
|
|
453 |
\begin{bubble}[9cm]
|
|
454 |
\begin{tabular}{@{\hspace{8mm}}llll@{\hspace{8mm}}}
|
|
455 |
\\
|
200
|
456 |
\multicolumn{4}{c}{\alert{\bf Speedup by Moore's Law}}\medskip\\
|
137
|
457 |
\textbf{1986:} & 3 days & \textbf{1996:} & 135 mins\\
|
|
458 |
\textbf{1988:} & 1.5 days & \textbf{1998:} & 67 mins\\
|
|
459 |
\textbf{1990:} & 18 hs & \textbf{2000:} & 33 mins\\
|
|
460 |
\textbf{1992:} & 9 hs & \textbf{2002:} & 16 mins\\
|
|
461 |
\textbf{1994:} & 4.5 hs & \multicolumn{2}{c}{???}\\
|
|
462 |
\\
|
|
463 |
\end{tabular}
|
|
464 |
\small Every two years, computers got twice as powerful.
|
|
465 |
\end{bubble}
|
|
466 |
\end{textblock}}
|
|
467 |
|
|
468 |
\end{frame}
|
|
469 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
470 |
|
|
471 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
472 |
\begin{frame}[c]
|
200
|
473 |
\frametitle{Seq \;vs\; Par}
|
137
|
474 |
|
|
475 |
\begin{center}
|
|
476 |
\begin{tabular}[t]{@{}l@{}l@{}}
|
200
|
477 |
\includegraphics[scale=0.14]{../pics/mand4.png} & \hspace{4mm}
|
|
478 |
\raisebox{0mm}{\includegraphics[scale=0.14]{../pics/mand3.png}}\\
|
|
479 |
\hspace{6mm}\includegraphics[scale=0.5]{../pics/cpu2.png} &
|
|
480 |
\hspace{11mm}\includegraphics[scale=0.5]{../pics/cpu1.png}
|
137
|
481 |
\end{tabular}
|
|
482 |
\end{center}
|
|
483 |
|
|
484 |
\only<2>{
|
|
485 |
\begin{textblock}{5}(12,2)
|
|
486 |
\begin{bubble}[2.1cm]
|
|
487 |
\footnotesize{}in Java or C++\\
|
|
488 |
\includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
|
|
489 |
\end{bubble}
|
|
490 |
\end{textblock}}
|
|
491 |
|
|
492 |
\only<3>{
|
200
|
493 |
\begin{textblock}{14.2}(1,13.5)
|
140
|
494 |
In FP: Once a variable is created, it is assigned a value and then
|
308
|
495 |
never changed again $\Rightarrow$ no synchronisation needed\smallskip\\
|
200
|
496 |
%%\small\textcolor{gray}{(Andrew's second favourite feature of C++)}
|
137
|
497 |
\end{textblock}}
|
|
498 |
|
|
499 |
\end{frame}
|
|
500 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
501 |
|
354
|
502 |
%\begin{frame}
|
|
503 |
%
|
|
504 |
%\end{frame}
|
137
|
505 |
|
354
|
506 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
507 |
%\begin{frame}[c, fragile]
|
|
508 |
%
|
|
509 |
%\mbox{}\bigskip\bigskip\bigskip
|
|
510 |
%
|
|
511 |
%\begin{lstlisting}[language=Scala,numbers=none]
|
|
512 |
%for (y <- (0 until H).par) {
|
|
513 |
% for (x <- (0 until W).par) {
|
|
514 |
%
|
|
515 |
% ...
|
|
516 |
%
|
|
517 |
% }
|
|
518 |
%}
|
|
519 |
%\end{lstlisting}
|
|
520 |
%
|
|
521 |
%
|
|
522 |
%\end{frame}
|
|
523 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
32
|
524 |
|
|
525 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
526 |
\begin{frame}[c]
|
23
|
527 |
\frametitle{Types}
|
|
528 |
|
|
529 |
\begin{itemize}
|
33
|
530 |
\item Base types\smallskip
|
23
|
531 |
|
33
|
532 |
\begin{tabular}{@{}l@{}}
|
23
|
533 |
\textcolor{codegreen}{\texttt{Int}},
|
|
534 |
\textcolor{codegreen}{\texttt{Long}},
|
|
535 |
\textcolor{codegreen}{\texttt{BigInt}},
|
|
536 |
\textcolor{codegreen}{\texttt{Float}},
|
|
537 |
\textcolor{codegreen}{\texttt{Double}}\\
|
|
538 |
\textcolor{codegreen}{\texttt{String}},
|
25
|
539 |
\textcolor{codegreen}{\texttt{Char}}\\
|
|
540 |
\textcolor{codegreen}{\texttt{Boolean}}
|
23
|
541 |
\end{tabular}
|
|
542 |
|
33
|
543 |
\item Compound types \smallskip
|
23
|
544 |
|
33
|
545 |
\begin{tabular}{@{}ll@{}}
|
23
|
546 |
\textcolor{codegreen}{\texttt{List[Int]}} & lists of Int's \\
|
|
547 |
\textcolor{codegreen}{\texttt{Set[Double]}} & sets of Double's \\
|
|
548 |
\textcolor{codegreen}{\texttt{(Int, String)}} & Int-String pair\\
|
|
549 |
\textcolor{codegreen}{\texttt{List[(BigInt, String)]}} &
|
|
550 |
lists of BigInt-String\\
|
|
551 |
& pairs\\
|
200
|
552 |
\textcolor{codegreen}{\texttt{List[List[Int]]}} & list of lists of Int's\\ \textcolor{codegreen}{\texttt{Option[Int]}} & options of Int's \\
|
23
|
553 |
\end{tabular}
|
|
554 |
|
|
555 |
\end{itemize}
|
|
556 |
|
|
557 |
\end{frame}
|
|
558 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
559 |
|
32
|
560 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
200
|
561 |
%\begin{frame}[c]
|
|
562 |
%\frametitle{An Http Request}
|
32
|
563 |
|
200
|
564 |
%\begin{textblock}{1}(2,5)
|
|
565 |
%\begin{tabular}{c}
|
|
566 |
%\includegraphics[scale=0.15]{../pics/servers.png}\\[-2mm]
|
|
567 |
%\small Server
|
|
568 |
%\end{tabular}
|
|
569 |
%\end{textblock}
|
32
|
570 |
|
200
|
571 |
%\begin{textblock}{1}(5.6,4)
|
|
572 |
% \begin{tikzpicture}[scale=1.1]
|
|
573 |
% \draw[white] (0,1) node (X) {};
|
|
574 |
% \draw[white] (2,1) node (Y) {};
|
|
575 |
% \draw[white] (0,0) node (X1) {};
|
|
576 |
% \draw[white] (2,0) node (Y1) {};
|
|
577 |
% \draw[white] (0,-1) node (X2) {};
|
|
578 |
% \draw[white] (2,-1) node (Y2) {};
|
|
579 |
% \draw[red, <-, line width = 2mm] (X) -- (Y);
|
|
580 |
% \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
|
|
581 |
% \draw[red, ->, line width = 2mm] (X1) -- (Y1);
|
|
582 |
% \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
|
|
583 |
% \draw[red, <-, line width = 2mm] (X2) -- (Y2);
|
|
584 |
% \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
|
|
585 |
% \end{tikzpicture}
|
|
586 |
%\end{textblock}
|
32
|
587 |
|
|
588 |
|
200
|
589 |
%\begin{textblock}{1}(9,5.5)
|
|
590 |
%\begin{tabular}{c}
|
|
591 |
%\includegraphics[scale=0.15]{../pics/laptop.png}\\[-2mm]
|
|
592 |
%\small Browser
|
|
593 |
%\end{tabular}
|
|
594 |
%\end{textblock}
|
|
595 |
%\end{frame}
|
32
|
596 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
597 |
|
|
598 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
200
|
599 |
%\begin{frame}[c]
|
|
600 |
%
|
|
601 |
%{\lstset{language=Java}\fontsize{7}{8}\selectfont
|
|
602 |
%\texttt{\lstinputlisting{URLReader.java}}}
|
|
603 |
%
|
|
604 |
%\end{frame}
|
32
|
605 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
606 |
|
33
|
607 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
356
|
608 |
\begin{frame}[c, fragile]
|
359
|
609 |
%%\frametitle{General Scheme of}
|
356
|
610 |
|
358
|
611 |
\small
|
|
612 |
\begin{lstlisting}[language=Scala,numbers=none]
|
|
613 |
def fname(arg1: ty1, arg2: ty2,..., argn: tyn): rty = {
|
356
|
614 |
|
358
|
615 |
....
|
356
|
616 |
|
|
617 |
}
|
|
618 |
\end{lstlisting}
|
|
619 |
|
|
620 |
|
|
621 |
\end{frame}
|
|
622 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
623 |
|
359
|
624 |
\begin{frame}[c, fragile]
|
|
625 |
|
|
626 |
\begin{lstlisting}[language=Scala,numbers=none]
|
|
627 |
def average(xs: List[Int]) : Int = {
|
|
628 |
val s = xs.sum
|
|
629 |
val n = xs.length
|
|
630 |
s / n
|
|
631 |
}
|
|
632 |
\end{lstlisting}
|
|
633 |
|
|
634 |
|
|
635 |
\end{frame}
|
|
636 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
309
|
641 |
|
356
|
642 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
643 |
%\begin{frame}[c]
|
|
644 |
% \frametitle{Coursework Dates}
|
|
645 |
%
|
|
646 |
%Similar to C++:\bigskip
|
|
647 |
%
|
|
648 |
%\begin{itemize}
|
|
649 |
% \item Preliminary Parts: Wednesdays 4pm
|
|
650 |
% \begin{itemize}
|
|
651 |
% \item Preliminary Part 6: 3\% (13 November)
|
|
652 |
% \item Preliminary Part 7: 4\% (20 November)
|
|
653 |
% \item Preliminary Part 8: 4\% (27 November)
|
|
654 |
% \item Preliminary Part 9: 4\% (5 December)
|
|
655 |
% \end{itemize}\medskip
|
|
656 |
% \item Core Part: 35\% (15 January 2020)\bigskip
|
|
657 |
%\end{itemize}
|
|
658 |
%\end{frame}
|
|
659 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
309
|
660 |
|
|
661 |
|
|
662 |
|
|
663 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
356
|
664 |
%\begin{frame}[c]
|
|
665 |
%\frametitle{Coursework}
|
|
666 |
%
|
|
667 |
%\begin{itemize}
|
|
668 |
%\item Sorry, I might have been a bit wordy:\\
|
|
669 |
% Part 6 of CW description is 7 pages, but
|
|
670 |
% I only needed \mbox{< 100} loc for \emph{all} Part 6.\bigskip
|
|
671 |
%
|
|
672 |
%\item there is feedback when pushing code to github\medskip
|
|
673 |
%
|
|
674 |
%\item there are \texttt{jar}-files you can use to test
|
|
675 |
% my reference implementation\bigskip
|
|
676 |
%
|
|
677 |
%\item we want you to learn FP!\smallskip\\ \alert{\bf no vars}, no mutable
|
|
678 |
% data-structures\\ \quad{}e.g.~no \texttt{Arrays}, no \texttt{ListBuffer}
|
|
679 |
%\end{itemize}
|
|
680 |
%
|
|
681 |
%\LEFTarrow{1}{11}{11.8}
|
|
682 |
%\end{frame}
|
140
|
683 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
684 |
|
|
685 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
686 |
|
|
687 |
\begin{frame}[c, fragile]
|
|
688 |
\frametitle{The Joy of Immutability}
|
|
689 |
|
|
690 |
\begin{itemize}
|
|
691 |
\item If you need to manipulate some data in a list say, then you make
|
|
692 |
a new list with the updated values, rather than revise the original
|
|
693 |
list. Easy!\medskip
|
|
694 |
|
|
695 |
{\small
|
|
696 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
697 |
val old_list = List(1, 2, 3, 5)
|
|
698 |
val new_list = 0 :: old_list
|
308
|
699 |
// -> List(0, 1, 2, 3, 4, 5)
|
140
|
700 |
\end{lstlisting}}
|
|
701 |
|
200
|
702 |
\item You do not have to be defensive about who can access the data.
|
|
703 |
|
|
704 |
\item You can look at your code in isolation.
|
140
|
705 |
\end{itemize}
|
|
706 |
\end{frame}
|
|
707 |
|
|
708 |
|
|
709 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
710 |
|
|
711 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
712 |
\begin{frame}[t]
|
|
713 |
\frametitle{Email: Hate 'val'}
|
|
714 |
|
308
|
715 |
\mbox{}\\[-23mm]\mbox{}
|
140
|
716 |
|
|
717 |
\begin{center}
|
|
718 |
\begin{bubble}[10.5cm]
|
354
|
719 |
Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\hspace{1cm}\medskip\\
|
140
|
720 |
|
|
721 |
Hello Mr Urban,\medskip\\
|
|
722 |
|
|
723 |
I just wanted to ask, how are we suppose to work
|
|
724 |
with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
|
|
725 |
this rule active at all? I’ve spent 4 hours not thinking on the
|
|
726 |
coursework, but how to bypass this annoying rule. What’s the whole
|
|
727 |
point of all these coursework, when we can’t use everything Scala
|
|
728 |
gives us?!?\medskip\\
|
|
729 |
|
|
730 |
Regards.\\
|
|
731 |
\mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
|
|
732 |
\end{bubble}
|
|
733 |
\end{center}
|
|
734 |
|
|
735 |
\end{frame}
|
|
736 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
737 |
|
|
738 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
739 |
\begin{frame}[c]
|
|
740 |
|
|
741 |
\mbox{}\\[-25mm]\mbox{}
|
|
742 |
|
|
743 |
\begin{center}
|
|
744 |
\begin{bubble}[10.5cm]
|
354
|
745 |
Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\hspace{1cm}\bigskip\bigskip\\
|
140
|
746 |
|
|
747 |
\textcolor{black!70}{
|
|
748 |
\textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
|
|
749 |
yada>>}}\bigskip\bigskip\bigskip
|
|
750 |
|
|
751 |
PS: What are you trying to do where you desperately want to use \texttt{var}?
|
|
752 |
\end{bubble}
|
|
753 |
\end{center}
|
|
754 |
|
|
755 |
\end{frame}
|
|
756 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
757 |
|
|
758 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
759 |
\begin{frame}[c,fragile]
|
|
760 |
|
|
761 |
\begin{textblock}{6}(0.5,0.5)
|
|
762 |
\begin{bubble}[11.5cm]
|
|
763 |
\small
|
354
|
764 |
Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\hspace{1cm}\medskip\\
|
140
|
765 |
|
|
766 |
\textbf{Right now my is\_legal function works fine:}
|
|
767 |
|
|
768 |
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
769 |
def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
|
|
770 |
var boolReturn = false
|
|
771 |
if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
|
|
772 |
else { var breakLoop = false
|
|
773 |
if(path == Nil) { boolReturn = true }
|
|
774 |
else { for(i <- 0 until path.length) {
|
|
775 |
if(breakLoop == false) {
|
|
776 |
if(path(i) == x) {
|
|
777 |
boolReturn = true
|
|
778 |
breakLoop = true
|
|
779 |
}
|
|
780 |
else { boolReturn = false }
|
|
781 |
} else breakLoop
|
|
782 |
}
|
|
783 |
}
|
|
784 |
boolReturn
|
|
785 |
}
|
|
786 |
\end{lstlisting}
|
|
787 |
\end{bubble}
|
|
788 |
\end{textblock}
|
|
789 |
|
|
790 |
\begin{textblock}{6}(8.2,11.8)
|
|
791 |
\begin{bubble}[5.5cm]\footnotesize\bf
|
|
792 |
\ldots{}but I can’t make it work with boolReturn being val. What approach would
|
|
793 |
you recommend in this case, and is using var in this case justified?
|
|
794 |
\end{bubble}
|
|
795 |
\end{textblock}
|
|
796 |
|
|
797 |
\only<2>{
|
|
798 |
\begin{textblock}{6}(0.3,11.8)
|
|
799 |
\begin{bubble}[3.1cm]
|
|
800 |
\textbf{Me:}
|
|
801 |
\raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}}
|
|
802 |
\end{bubble}
|
|
803 |
\end{textblock}}
|
|
804 |
|
|
805 |
\end{frame}
|
|
806 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
807 |
|
|
808 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
809 |
\begin{frame}[t,fragile]
|
|
810 |
|
|
811 |
\mbox{}\\[-25mm]\mbox{}
|
|
812 |
|
|
813 |
\begin{textblock}{6}(0.5,2)
|
|
814 |
\begin{bubble}[11.5cm]
|
|
815 |
Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
|
|
816 |
\small
|
|
817 |
|
|
818 |
OK. So you want to make sure that the \texttt{x}-position is not outside the
|
|
819 |
board....and furthermore you want to make sure that the \texttt{x}-position
|
|
820 |
is not yet in the path list. How about something like\bigskip
|
|
821 |
|
|
822 |
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
823 |
def is_legal(dim: Int, path: Path)(x: Pos): Boolean =
|
|
824 |
...<<some board conditions>>... && !path.contains(x)
|
|
825 |
\end{lstlisting}\bigskip
|
|
826 |
|
|
827 |
\small Does not even contain a \texttt{val}.
|
|
828 |
\end{bubble}
|
|
829 |
\end{textblock}
|
|
830 |
|
|
831 |
\begin{textblock}{6}(7,12)
|
|
832 |
\footnotesize\textcolor{black!50}{(This is all on one line)}
|
|
833 |
\end{textblock}
|
|
834 |
|
|
835 |
\end{frame}
|
|
836 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
837 |
|
|
838 |
|
|
839 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
840 |
\begin{frame}[t,fragile]
|
|
841 |
|
|
842 |
\mbox{}\\[-15mm]\mbox{}
|
|
843 |
|
|
844 |
\begin{textblock}{6}(1,3)
|
|
845 |
\begin{bubble}[10.5cm]
|
|
846 |
Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
|
|
847 |
|
|
848 |
THANK YOU! You made me change my coding perspective. Because of you,
|
|
849 |
I figured out the next one\ldots
|
|
850 |
\end{bubble}
|
|
851 |
\end{textblock}
|
|
852 |
|
|
853 |
\only<2>{
|
|
854 |
\begin{textblock}{6}(0.3,11.8)
|
|
855 |
\begin{bubble}[3.1cm]
|
|
856 |
\textbf{Me:}
|
|
857 |
\raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}}
|
|
858 |
\end{bubble}
|
|
859 |
\end{textblock}}
|
|
860 |
|
|
861 |
\end{frame}
|
|
862 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
863 |
|
|
864 |
|
|
865 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
866 |
\begin{frame}[c]
|
309
|
867 |
\frametitle{Conclusion for Today}
|
33
|
868 |
|
|
869 |
\begin{itemize}
|
309
|
870 |
\item Scala is still under development, 2.13.1 came out in Sept.\\
|
|
871 |
(the compiler is terribly slow)\medskip
|
33
|
872 |
\item {\bf\url{http://www.scala-lang.org/}}\bigskip
|
140
|
873 |
|
|
874 |
\item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives
|
|
875 |
you a lot of rope to shoot yourself\bigskip
|
33
|
876 |
|
140
|
877 |
\item learning functional programming is not easy\ldots{}when you have
|
200
|
878 |
spent all of your career thinking in an imperative way, it is hard to
|
140
|
879 |
change\bigskip\medskip
|
|
880 |
|
200
|
881 |
\item hope you have fun with Scala and the assignments
|
33
|
882 |
\end{itemize}
|
|
883 |
\end{frame}
|
|
884 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
885 |
|
|
886 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
356
|
887 |
%\begin{frame}[c]
|
|
888 |
%\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
|
|
889 |
%
|
|
890 |
%\begin{center}
|
|
891 |
% \begin{tabular}[t]{@{}l@{}l@{}}
|
|
892 |
% \includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
|
|
893 |
% \raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}
|
|
894 |
% \end{tabular}
|
|
895 |
%\end{center}
|
|
896 |
%
|
|
897 |
%\begin{center}
|
|
898 |
% My Office Hours: Thursdays 12 -- 14\\
|
|
899 |
% And specifically for Scala: Tuesdays 10:45 -- 11:45
|
|
900 |
%\end{center}
|
|
901 |
%\end{frame}
|
33
|
902 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
314
|
903 |
|
|
904 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
356
|
905 |
%\begin{frame}[t]%
|
|
906 |
%
|
|
907 |
%\begin{center}
|
|
908 |
%\includegraphics[scale=0.4]{../pics/blow.png}
|
|
909 |
%\end{center}
|
|
910 |
%
|
|
911 |
%\begin{textblock}{14}(2,12.4)
|
|
912 |
%\Large\bf{}Mind-Blowing\\ Programming Languages: C/C++
|
|
913 |
%\end{textblock}
|
|
914 |
%\end{frame}
|
314
|
915 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
916 |
|
360
|
917 |
\begin{frame}[c]
|
|
918 |
\begin{center}
|
|
919 |
\includegraphics[scale=0.4]{../pics/fun.png}
|
|
920 |
\end{center}
|
|
921 |
\end{frame}
|
32
|
922 |
|
416
|
923 |
\begin{frame}<1-20>[t]
|
360
|
924 |
|
|
925 |
\end{frame}
|
32
|
926 |
|
22
|
927 |
\end{document}
|
|
928 |
|
|
929 |
%%% Local Variables:
|
|
930 |
%%% mode: latex
|
|
931 |
%%% TeX-master: t
|
|
932 |
%%% End:
|
|
933 |
|
140
|
934 |
|
|
935 |
“Functional programming is often regarded as the best-kept secret of
|
|
936 |
scientific modelers, mathematicians, artificial intelligence
|
|
937 |
researchers, financial institutions, graphic designers, CPU designers,
|
|
938 |
compiler programmers, and telecommunications engineers.”
|
|
939 |
|
|
940 |
The Wikipedia F# page |