\documentclass[dvipsnames,14pt,t,xelatex]{beamer}
\usepackage{../slides}
\usepackage{../graphics}
\usepackage{../langs}
%%\usepackage{../data}
\usepackage[export]{adjustbox}
\hfuzz=220pt
%\setmonofont[Scale=.88]{Consolas}
%\newfontfamily{\consolas}{Consolas}
\lstset{language=Scala,
style=mystyle,
numbersep=0pt,
numbers=none,
xleftmargin=0mm}
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
% beamer stuff
\renewcommand{\slidecaption}{PEP (Scala) 03, King's College London}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{%
\begin{tabular}{@ {}c@ {}}
\\[5mm]
\huge PEP Scala (3)
\end{tabular}}
\normalsize
\begin{center}
\begin{tabular}{ll}
Email: & christian.urban at kcl.ac.uk\\
Office: & N7.07 (North Wing, Bush House)\\
Slides \& Code: & KEATS\medskip\\
Office Hours: & \alert{next Monday} 11 -- 12 \& 13 -- 14\\
\end{tabular}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Marks for CW6 (Part 1 + 2)}
Raw marks (234 submissions):
\begin{itemize}
\item 6\%: \hspace{4mm}163 students
\item 5\%: \hspace{4mm}29
\item 4\%: \hspace{4mm}3
\item 3\%: \hspace{4mm}13
\item 2\%: \hspace{4mm}3
\item 1\%: \hspace{4mm}0
\item 0\%: \hspace{4mm}23
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def collatz(n: Long) : Long =
{
val toReturn = collatzHelper(n, 0)
toReturn
}
\end{lstlisting}
\pause
\bigskip
\rule{11cm}{0.3mm}
\bigskip
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def collatz(n: Long) : Long =
collatzHelper(n, 0)
\end{lstlisting}\pause
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
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)}
\end{lstlisting}\bigskip
\tiny
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
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)}
\end{lstlisting}\pause
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\small
\begin{lstlisting}[language=Scala, xleftmargin=-4mm,numbers=left]
def process_ratings(lines: List[String]) = {
val values = List[(String,String)]()
for(line <- lines) {
val splitList = ...
if(splitList(2).toInt >= 4){
val userID = splitList(0)
val movieID = splitList(1)
val tuple = (userID, movieID)
tuple :: values
}
}
values
}
\end{lstlisting}
\normalsize
What does this function (always) return?
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Jumping Towers}
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[line width=1mm,cap=round] (0,0) -- (5,0);
\draw[line width=1mm,cap=round] (0,1) -- (5,1);
\draw[line width=1mm,cap=round] (0,0) -- (0,1);
\node at (0.5,0.5) {\textbf{\Large 3}};
\draw[line width=1mm,cap=round] (1,0) -- (1,1);
\node at (1.5,0.5) {\textbf{\Large 4}};
\draw[line width=1mm,cap=round] (2,0) -- (2,1);
\node at (2.5,0.5) {\textbf{\Large 2}};
\draw[line width=1mm,cap=round] (3,0) -- (3,1);
\node at (3.5,0.5) {\textbf{\Large 0}};
\draw[line width=1mm,cap=round] (4,0) -- (4,1);
\node at (4.5,0.5) {\textbf{\Large 1}};
\draw[line width=1mm,cap=round] (5,0) -- (5,1);
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (1.5,1);
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (2.5,1);
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (3.5,1);
\draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (3.5,0);
\draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (4.5,0);
\draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (4.5,1) to (5.7,1);
\node at (5.7, 0.8) {End};
\end{tikzpicture}
\end{center}\bigskip
shortest: 3 $\rightarrow$ 4 $\rightarrow$ End
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{``Children'' / moves}
\begin{center}
\begin{tikzpicture}
[grow=right,level distance=30mm,child anchor=north,line width=0.5mm]
\node {$[3,4,2,0,1]$}
child {node {$[0,1]$}}
child {node {$[2,0,1]$}
child {node {$[1]$} child [level distance=13mm] {node {End}}}
child {node {$[0,1]$}}
}
child {node {$[4,2,0,1]$\ldots}};
\end{tikzpicture}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: