|
1 \documentclass[dvipsnames,14pt,t,xelatex]{beamer} |
|
2 \usepackage{../slides} |
|
3 \usepackage{../graphics} |
|
4 \usepackage{../langs} |
|
5 %%\usepackage{../data} |
|
6 \usepackage[export]{adjustbox} |
|
7 |
|
8 \hfuzz=220pt |
|
9 |
|
10 %\setmonofont[Scale=.88]{Consolas} |
|
11 %\newfontfamily{\consolas}{Consolas} |
|
12 |
|
13 \lstset{language=Scala, |
|
14 style=mystyle, |
|
15 numbersep=0pt, |
|
16 numbers=none, |
|
17 xleftmargin=0mm} |
|
18 |
|
19 \newcommand{\bl}[1]{\textcolor{blue}{#1}} |
|
20 |
|
21 % beamer stuff |
|
22 \renewcommand{\slidecaption}{PEP (Scala) 03, King's College London} |
|
23 |
|
24 \begin{filecontents}{re3a.data} |
|
25 1 0.00003 |
|
26 500001 0.22527 |
|
27 1000001 0.62752 |
|
28 1500001 0.88485 |
|
29 2000001 1.39815 |
|
30 2500001 1.68619 |
|
31 3000001 1.94957 |
|
32 3500001 2.15878 |
|
33 4000001 2.59918 |
|
34 4500001 5.90679 |
|
35 5000001 13.11295 |
|
36 5500001 19.15376 |
|
37 6000001 40.16373 |
|
38 \end{filecontents} |
|
39 \begin{filecontents}{re-python2.data} |
|
40 1 0.033 |
|
41 5 0.036 |
|
42 10 0.034 |
|
43 15 0.036 |
|
44 18 0.059 |
|
45 19 0.084 |
|
46 20 0.141 |
|
47 21 0.248 |
|
48 22 0.485 |
|
49 23 0.878 |
|
50 24 1.71 |
|
51 25 3.40 |
|
52 26 7.08 |
|
53 27 14.12 |
|
54 28 26.69 |
|
55 \end{filecontents} |
|
56 |
|
57 \begin{filecontents}{re-java.data} |
|
58 5 0.00298 |
|
59 10 0.00418 |
|
60 15 0.00996 |
|
61 16 0.01710 |
|
62 17 0.03492 |
|
63 18 0.03303 |
|
64 19 0.05084 |
|
65 20 0.10177 |
|
66 21 0.19960 |
|
67 22 0.41159 |
|
68 23 0.82234 |
|
69 24 1.70251 |
|
70 25 3.36112 |
|
71 26 6.63998 |
|
72 27 13.35120 |
|
73 28 29.81185 |
|
74 \end{filecontents} |
|
75 |
|
76 \begin{document} |
|
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
78 \begin{frame}[t] |
|
79 \frametitle{% |
|
80 \begin{tabular}{@ {}c@ {}} |
|
81 \\[5mm] |
|
82 \huge PEP Scala (3) |
|
83 \end{tabular}} |
|
84 |
|
85 \normalsize |
|
86 \begin{center} |
|
87 \begin{tabular}{ll} |
|
88 Email: & christian.urban at kcl.ac.uk\\ |
|
89 Office: & N7.07 (North Wing, Bush House)\\ |
|
90 Slides \& Code: & KEATS\medskip\\ |
|
91 Scala Office & \\ |
|
92 Hours: & Thursdays 11 -- 13\\ |
|
93 \end{tabular} |
|
94 \end{center} |
|
95 |
|
96 |
|
97 \end{frame} |
|
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
99 |
|
100 |
|
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
102 \begin{frame}[c,fragile] |
|
103 |
|
104 \begin{textblock}{6}(0.5,0.5) |
|
105 \begin{bubble}[11.5cm] |
|
106 \footnotesize |
|
107 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
108 import java.util.concurrent._ |
|
109 import java.util.concurrent.atomic._ |
|
110 |
|
111 def collatz(input:Int){ |
|
112 CollatzConjecture(input); |
|
113 println(count.get()); |
|
114 } |
|
115 def collatz_max(input:Int){ |
|
116 val List = new Array[Int](input) |
|
117 for (i <- 0 to input-1){ |
|
118 CollaĵConjecture(i); |
|
119 List(i)=count.get(); |
|
120 count.set(0); |
|
121 } |
|
122 val max = new AtomicInteger(); |
|
123 max.set(List(0)); |
|
124 val index = new AtomicInteger(); |
|
125 index.set(1); |
|
126 |
|
127 \end{lstlisting} |
|
128 \end{bubble} |
|
129 \end{textblock} |
|
130 |
|
131 \end{frame} |
|
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
133 |
|
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
135 \begin{frame}[c,fragile] |
|
136 |
|
137 \begin{textblock}{6}(0.5,0.5) |
|
138 \begin{bubble}[11.5cm] |
|
139 \footnotesize |
|
140 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
141 for(i<-0 to input-1){ |
|
142 val temp :Int=max.get(); |
|
143 if (temp < List(i)){ |
|
144 max.set(List(i)); |
|
145 index.set(i); |
|
146 } |
|
147 } |
|
148 println("("+max.get() +","+ index.get()+ ")"); |
|
149 } |
|
150 |
|
151 def CollatzConjecture(n: Long): Long = { |
|
152 count.incrementAndGet(); |
|
153 if (n <= 1) |
|
154 1 |
|
155 else if (n\%2 ==0) |
|
156 CollatzConjecture(n/2); |
|
157 else |
|
158 CollatzConjecture((3*n)+1); |
|
159 } |
|
160 } |
|
161 \end{lstlisting} |
|
162 \end{bubble} |
|
163 \end{textblock} |
|
164 |
|
165 \end{frame} |
|
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
167 |
|
168 |
|
169 |
|
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
171 \begin{frame}[c] |
|
172 \frametitle{CW3 (1 Part): Regexes} |
|
173 |
|
174 \begin{center} |
|
175 Graphs: $(a^*)^* b$ and strings $\underbrace{\;a\ldots a\;}_{n}$\bigskip |
|
176 |
|
177 \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}} |
|
178 \raisebox{6mm}{\begin{tikzpicture} |
|
179 \begin{axis}[ |
|
180 xlabel={$n$}, |
|
181 x label style={at={(1.05,0.0)}}, |
|
182 ylabel={time in secs}, |
|
183 enlargelimits=false, |
|
184 xtick={0,5,...,30}, |
|
185 xmax=33, |
|
186 ymax=35, |
|
187 ytick={0,5,...,30}, |
|
188 scaled ticks=false, |
|
189 axis lines=left, |
|
190 width=5.5cm, |
|
191 height=5cm, |
|
192 legend entries={Python, Java 8}, |
|
193 legend pos=north west, |
|
194 legend cell align=left] |
|
195 \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
|
196 \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
197 \end{axis} |
|
198 \end{tikzpicture}} |
|
199 & |
|
200 \onslide<2>{\begin{tikzpicture} |
|
201 \begin{axis}[ |
|
202 xlabel={$n$}, |
|
203 x label style={at={(1.05,0.0)}}, |
|
204 ylabel={time in secs}, |
|
205 enlargelimits=false, |
|
206 ymax=35, |
|
207 ytick={0,5,...,30}, |
|
208 axis lines=left, |
|
209 %%scaled ticks=false, |
|
210 width=5.5cm, |
|
211 height=5cm] |
|
212 %%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data}; |
|
213 \addplot[red,mark=square*,mark options={fill=white}] table {re3a.data}; |
|
214 \end{axis} |
|
215 \end{tikzpicture}} |
|
216 \end{tabular} |
|
217 \end{center} |
|
218 |
|
219 \hfill\small\url{https://vimeo.com/112065252} |
|
220 \end{frame} |
|
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
222 |
|
223 \begin{frame}[c] |
|
224 \frametitle{Where to go on from here?} |
|
225 |
|
226 \begin{itemize} |
|
227 \item Martin Odersky (EPFL)\ldots he is currently throwing out everything |
|
228 and starts again with the dotty compiler for Scala\medskip |
|
229 |
|
230 \item Elm (\url{http://elm-lang.org})\ldots web applications with style\medskip |
|
231 |
|
232 \item Haskell, Ocaml, Standard ML, Scheme, \ldots |
|
233 \end{itemize} |
|
234 \end{frame} |
|
235 |
|
236 |
|
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
238 |
|
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
240 \begin{frame}[c,fragile] |
|
241 \frametitle{\alert{Questions?}} |
|
242 |
|
243 {\tiny |
|
244 \begin{verbatim} |
|
245 * |
|
246 * * |
|
247 * * |
|
248 * * * * |
|
249 * * |
|
250 * * * * |
|
251 * * * * |
|
252 * * * * * * * * |
|
253 * * |
|
254 * * * * |
|
255 * * * * |
|
256 * * * * * * * * |
|
257 * * * * |
|
258 * * * * * * * * |
|
259 * * * * * * * * |
|
260 * * * * * * * * * * * * * * * * |
|
261 * * |
|
262 * * * * |
|
263 * * * * |
|
264 * * * * * * * * |
|
265 * * * * |
|
266 * * * * * * * * |
|
267 * * * * * * * * |
|
268 * * * * * * * * * * * * * * * * |
|
269 * * * * |
|
270 * * * * * * * * |
|
271 * * * * * * * * |
|
272 * * * * * * * * * * * * * * * * |
|
273 * * * * * * * * |
|
274 * * * * * * * * * * * * * * * * |
|
275 * * * * * * * * * * * * * * * * |
|
276 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
277 \end{verbatim}} |
|
278 |
|
279 |
|
280 \begin{textblock}{6}(8.5,3.5) |
|
281 \begin{bubble}[5cm] |
|
282 \footnotesize |
|
283 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
284 ++++++++[>+>++++<<-]>++>> |
|
285 +<[-[>>+<<-]+>>]>+[-<<<[- |
|
286 >[+[-]+>++>>>-<<]<[<]>>++ |
|
287 ++++[<<+++++>>-]+<<++.[-] |
|
288 <<]>.>+[>>]>+] |
|
289 \end{lstlisting} |
|
290 \end{bubble} |
|
291 \end{textblock} |
|
292 |
|
293 \end{frame} |
|
294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
295 |
|
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
297 |
|
298 \begin{frame}[c] |
|
299 \frametitle{Marks for CW6 (Part 1 + 2)} |
|
300 |
|
301 Raw marks: |
|
302 |
|
303 \begin{itemize} |
|
304 \item 6\%: 154 students |
|
305 \item 5\%: 66 |
|
306 \item 4\%: 18 |
|
307 \item 3\%: 13 |
|
308 \item 2\%: 2 |
|
309 \item 1\%: 1 |
|
310 \item 0\%: 21 |
|
311 \end{itemize} |
|
312 \end{frame} |
|
313 |
|
314 |
|
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
316 |
|
317 \end{document} |
|
318 |
|
319 |
|
320 \end{document} |
|
321 |
|
322 %%% Local Variables: |
|
323 %%% mode: latex |
|
324 %%% TeX-master: t |
|
325 %%% End: |
|
326 |