\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: & S1.27 (1st floor Strand Building)\\
Slides \& Code: & KEATS
\end{tabular}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c, fragile]
\frametitle{The Joy of Immutability}
\begin{itemize}
\item If you need to manipulate some data in a list say, then you make
a new list with the updated values, rather than revise the original
list. Easy!\medskip
{\small
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
val old_list = List(1, 2, 3, 5)
val new_list = 0 :: old_list
\end{lstlisting}}
\item You do not have to be defensive about who can access the data
(concurrency, lazyness).
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Email: Hate 'val'}
\mbox{}\\[-25mm]\mbox{}
\begin{center}
\begin{bubble}[10.5cm]
Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
Hello Mr Urban,\medskip\\
I just wanted to ask, how are we suppose to work
with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
this rule active at all? I’ve spent 4 hours not thinking on the
coursework, but how to bypass this annoying rule. What’s the whole
point of all these coursework, when we can’t use everything Scala
gives us?!?\medskip\\
Regards.\\
\mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
\end{bubble}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\mbox{}\\[-25mm]\mbox{}
\begin{center}
\begin{bubble}[10.5cm]
Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
\textcolor{black!70}{
\textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
yada>>}}\bigskip\bigskip\bigskip
PS: What are you trying to do where you desperately want to use \texttt{var}?
\end{bubble}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\begin{textblock}{6}(0.5,0.5)
\begin{bubble}[11.5cm]
\small
Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\
\textbf{Right now my is\_legal function works fine:}
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
var boolReturn = false
if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
else { var breakLoop = false
if(path == Nil) { boolReturn = true }
else { for(i <- 0 until path.length) {
if(breakLoop == false) {
if(path(i) == x) {
boolReturn = true
breakLoop = true
}
else { boolReturn = false }
} else breakLoop
}
}
boolReturn
}
\end{lstlisting}
\end{bubble}
\end{textblock}
\begin{textblock}{6}(8.2,11.8)
\begin{bubble}[5.5cm]\footnotesize\bf
\ldots{}but I can’t make it work with boolReturn being val. What approach would
you recommend in this case, and is using var in this case justified?
\end{bubble}
\end{textblock}
\only<2>{
\begin{textblock}{6}(0.3,11.8)
\begin{bubble}[3.1cm]
\textbf{Me:} \includegraphics[scale=0.08, valign=t]{../pics/throwup.jpg}
\end{bubble}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t,fragile]
\mbox{}\\[-25mm]\mbox{}
\begin{textblock}{6}(0.5,2)
\begin{bubble}[11.5cm]
Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
\small
OK. So you want to make sure that the \texttt{x}-position is not outside the
board....and furthermore you want to make sure that the \texttt{x}-position
is not yet in the path list. How about something like\bigskip
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def is_legal(dim: Int, path: Path)(x: Pos): Boolean =
...<<some board conditions>>... && !path.contains(x)
\end{lstlisting}\bigskip
\small Does not even contain a \texttt{val}.
\end{bubble}
\end{textblock}
\begin{textblock}{6}(7,12)
\footnotesize\textcolor{black!50}{(This is all on one line)}
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t,fragile]
\mbox{}\\[-15mm]\mbox{}
\begin{textblock}{6}(1,3)
\begin{bubble}[10.5cm]
Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
THANK YOU! You made me change my coding perspective. Because of you,
I figured out the next one\ldots
\end{bubble}
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{CW3: Regexes (1 Part)}
\begin{center}
Graphs: $(a^*)^* b$ and strings $\underbrace{\;a\ldots a\;}_{n}$\bigskip
\begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}}
\raisebox{6mm}{\begin{tikzpicture}
\begin{axis}[
xlabel={$n$},
x label style={at={(1.05,0.0)}},
ylabel={time in secs},
enlargelimits=false,
xtick={0,5,...,30},
xmax=33,
ymax=35,
ytick={0,5,...,30},
scaled ticks=false,
axis lines=left,
width=5.5cm,
height=5cm,
legend entries={Python, Java},
legend pos=north west,
legend cell align=left]
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
\end{axis}
\end{tikzpicture}}
&
\onslide<2>{\begin{tikzpicture}
\begin{axis}[
xlabel={$n$},
x label style={at={(1.05,0.0)}},
ylabel={time in secs},
enlargelimits=false,
ymax=35,
ytick={0,5,...,30},
axis lines=left,
%%scaled ticks=false,
width=5.5cm,
height=5cm]
%%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data};
\addplot[red,mark=square*,mark options={fill=white}] table {re3a.data};
\end{axis}
\end{tikzpicture}}
\end{tabular}
\end{center}
\hfill\small\url{https://vimeo.com/112065252}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Where to go on from here?}
\begin{itemize}
\item Martin Odersky (EPFL)\ldots he is currently throwing out everything
and starts again with the dotty compiler for Scala\medskip
\item Elm (\url{http://elm-lang.org})\ldots web applications with style\medskip
\item Haskell, Ocaml, Standard ML, Scheme, \ldots
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
\mbox{}\footnotesize
Thanks: ``\it{}By the way - Scala is really getting quite fun
when you start to get the hang of it\ldots''
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Marks for CW6 (Part 1)}
Absolute raw marks, alleged collusions still included:
\begin{itemize}
\item 0\%: 18 students
\item 1\%: 2
\item 2\%: 11
\item 3\%: 29
\item 4\%: 18
\item 5\%: 33
\item 6\%: 55
\item 7\%: 62
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: