66
|
1 |
\documentclass[dvipsnames,14pt,t,xelatex]{beamer}
|
|
2 |
\usepackage{../slides}
|
|
3 |
\usepackage{../graphics}
|
|
4 |
\usepackage{../langs}
|
155
|
5 |
%%\usepackage{../data}
|
67
|
6 |
\usepackage[export]{adjustbox}
|
66
|
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
|
67
|
22 |
\renewcommand{\slidecaption}{PEP (Scala) 03, King's College London}
|
66
|
23 |
|
|
24 |
\begin{document}
|
|
25 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
26 |
\begin{frame}[t]
|
|
27 |
\frametitle{%
|
|
28 |
\begin{tabular}{@ {}c@ {}}
|
|
29 |
\\[5mm]
|
67
|
30 |
\huge PEP Scala (3)
|
66
|
31 |
\end{tabular}}
|
|
32 |
|
|
33 |
\normalsize
|
|
34 |
\begin{center}
|
|
35 |
\begin{tabular}{ll}
|
155
|
36 |
Email: & christian.urban at kcl.ac.uk\\
|
|
37 |
Office: & N7.07 (North Wing, Bush House)\\
|
|
38 |
Slides \& Code: & KEATS\medskip\\
|
217
|
39 |
Office Hours: & \alert{next Monday} 11 -- 12 \& 13 -- 14\\
|
66
|
40 |
\end{tabular}
|
|
41 |
\end{center}
|
|
42 |
|
|
43 |
|
|
44 |
\end{frame}
|
|
45 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
46 |
|
217
|
47 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
48 |
|
|
49 |
\begin{frame}[c]
|
|
50 |
\frametitle{Marks for CW6 (Part 1 + 2)}
|
|
51 |
|
|
52 |
Raw marks (234 submissions):
|
|
53 |
|
|
54 |
\begin{itemize}
|
|
55 |
\item 6\%: \hspace{4mm}163 students
|
|
56 |
\item 5\%: \hspace{4mm}29
|
|
57 |
\item 4\%: \hspace{4mm}3
|
|
58 |
\item 3\%: \hspace{4mm}13
|
|
59 |
\item 2\%: \hspace{4mm}3
|
|
60 |
\item 1\%: \hspace{4mm}0
|
|
61 |
\item 0\%: \hspace{4mm}23
|
|
62 |
\end{itemize}
|
|
63 |
\end{frame}
|
|
64 |
|
|
65 |
|
|
66 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
67 |
|
|
68 |
|
66
|
69 |
|
|
70 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
67
|
71 |
\begin{frame}[c,fragile]
|
|
72 |
|
155
|
73 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
217
|
74 |
def collatz(n: Long) : Long =
|
|
75 |
{
|
|
76 |
val toReturn = collatzHelper(n, 0)
|
|
77 |
toReturn
|
|
78 |
}
|
|
79 |
\end{lstlisting}
|
|
80 |
|
|
81 |
\pause
|
|
82 |
\bigskip
|
|
83 |
\rule{11cm}{0.3mm}
|
|
84 |
\bigskip
|
67
|
85 |
|
217
|
86 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
87 |
def collatz(n: Long) : Long =
|
|
88 |
collatzHelper(n, 0)
|
|
89 |
\end{lstlisting}\pause
|
|
90 |
|
|
91 |
|
|
92 |
\end{frame}
|
|
93 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
94 |
|
|
95 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
96 |
\begin{frame}[c,fragile]
|
|
97 |
|
|
98 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
99 |
def collatz_max(bnd: Long) : (Long,Long) = {val lst = for(a<-(1 to bnd.toInt)) yield (collatz(a),a.toLong);val lst2 = lst.sortBy(_._1);lst2(lst2.length-1)}
|
|
100 |
\end{lstlisting}\bigskip
|
|
101 |
|
|
102 |
\tiny
|
|
103 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
|
|
104 |
def collatz_max(bnd: Long) : (Long,Long) = {val lst = for(a<-(1 to bnd.toInt)) yield (collatz(a),a.toLong);val lst2 = lst.sortBy(_._1);lst2(lst2.length-1)}
|
|
105 |
\end{lstlisting}\pause
|
|
106 |
|
67
|
107 |
|
|
108 |
\end{frame}
|
|
109 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
110 |
|
|
111 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
155
|
112 |
\begin{frame}[c,fragile]
|
67
|
113 |
|
217
|
114 |
\small
|
|
115 |
\begin{lstlisting}[language=Scala, xleftmargin=-4mm,numbers=left]
|
|
116 |
def process_ratings(lines: List[String]) = {
|
|
117 |
val values = List[(String,String)]()
|
|
118 |
|
|
119 |
for(line <- lines){
|
|
120 |
val splitList = line.split(",").toList
|
67
|
121 |
|
217
|
122 |
if(splitList(2).toInt >= 4){
|
|
123 |
val userID = splitList(0)
|
|
124 |
val movieID = splitList(1)
|
|
125 |
val tuple = (userID, movieID)
|
|
126 |
tuple :: values
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
values
|
155
|
131 |
}
|
|
132 |
\end{lstlisting}
|
217
|
133 |
|
|
134 |
\normalsize
|
|
135 |
What does this function always return?
|
|
136 |
|
67
|
137 |
|
|
138 |
\end{frame}
|
|
139 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
140 |
|
|
141 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
142 |
|
68
|
143 |
\begin{frame}[c]
|
217
|
144 |
\frametitle{Jumping Towers}
|
|
145 |
|
|
146 |
\begin{center}
|
|
147 |
\begin{tikzpicture}[scale=1.2]
|
|
148 |
\draw[line width=1mm,cap=round] (0,0) -- (5,0);
|
|
149 |
\draw[line width=1mm,cap=round] (0,1) -- (5,1);
|
|
150 |
|
|
151 |
\draw[line width=1mm,cap=round] (0,0) -- (0,1);
|
|
152 |
\node at (0.5,0.5) {\textbf{\Large 3}};
|
|
153 |
|
|
154 |
\draw[line width=1mm,cap=round] (1,0) -- (1,1);
|
|
155 |
\node at (1.5,0.5) {\textbf{\Large 4}};
|
|
156 |
|
|
157 |
\draw[line width=1mm,cap=round] (2,0) -- (2,1);
|
|
158 |
\node at (2.5,0.5) {\textbf{\Large 2}};
|
67
|
159 |
|
217
|
160 |
\draw[line width=1mm,cap=round] (3,0) -- (3,1);
|
|
161 |
\node at (3.5,0.5) {\textbf{\Large 0}};
|
|
162 |
|
|
163 |
\draw[line width=1mm,cap=round] (4,0) -- (4,1);
|
|
164 |
|
|
165 |
\node at (4.5,0.5) {\textbf{\Large 1}};
|
|
166 |
|
|
167 |
\draw[line width=1mm,cap=round] (5,0) -- (5,1);
|
67
|
168 |
|
217
|
169 |
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (1.5,1);
|
|
170 |
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (2.5,1);
|
|
171 |
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (3.5,1);
|
|
172 |
|
|
173 |
\draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (3.5,0);
|
|
174 |
\draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (4.5,0);
|
67
|
175 |
|
217
|
176 |
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (4.5,1) to (5.7,1);
|
|
177 |
\node at (5.7, 0.8) {End};
|
|
178 |
\end{tikzpicture}
|
|
179 |
\end{center}\bigskip
|
|
180 |
|
|
181 |
|
|
182 |
shortest: 3 $\rightarrow$ 4 $\rightarrow$ End
|
|
183 |
|
67
|
184 |
\end{frame}
|
|
185 |
|
|
186 |
|
|
187 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
188 |
|
70
|
189 |
|
|
190 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
191 |
|
|
192 |
\begin{frame}[c]
|
217
|
193 |
\frametitle{``Children'' / moves}
|
70
|
194 |
|
217
|
195 |
\begin{center}
|
|
196 |
\begin{tikzpicture}
|
|
197 |
[grow=right,level distance=30mm,child anchor=north,line width=0.5mm]
|
|
198 |
\node {$[3,4,2,0,1]$}
|
|
199 |
child {node {$[0,1]$}}
|
|
200 |
child {node {$[2,0,1]$}
|
|
201 |
child {node {$[1]$} child [level distance=13mm] {node {End}}}
|
|
202 |
child {node {$[0,1]$}}
|
|
203 |
}
|
|
204 |
child {node {$[4,2,0,1]$\ldots}};
|
|
205 |
\end{tikzpicture}
|
|
206 |
\end{center}
|
|
207 |
|
|
208 |
|
|
209 |
|
70
|
210 |
\end{frame}
|
|
211 |
|
|
212 |
|
|
213 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
214 |
|
217
|
215 |
|
|
216 |
|
66
|
217 |
\end{document}
|
|
218 |
|
|
219 |
|
|
220 |
\end{document}
|
|
221 |
|
|
222 |
%%% Local Variables:
|
|
223 |
%%% mode: latex
|
|
224 |
%%% TeX-master: t
|
|
225 |
%%% End:
|
|
226 |
|