diff -r 8aaf187d25f0 -r e45d2890749d slides/slides02.tex --- a/slides/slides02.tex Mon Nov 09 17:49:12 2020 +0000 +++ b/slides/slides02.tex Sat Nov 14 00:40:47 2020 +0000 @@ -1,5 +1,5 @@ % !TEX program = xelatex -\documentclass[dvipsnames,14pt,t,xelatex]{beamer} +\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} %\usepackage{chessboard} %\usepackage[LSBC4,T1]{fontenc} \usepackage{../slides} @@ -46,10 +46,10 @@ \begin{center} \begin{tabular}{ll} Email: & christian.urban at kcl.ac.uk\\ - Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\ + %Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\ Slides \& Code: & KEATS\bigskip\\ - Office Hours: & Thursdays 12:00 -- 14:00\\ - Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\ + %Office Hours: & Thursdays 12:00 -- 14:00\\ + %Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\ \end{tabular} \end{center} @@ -57,254 +57,31 @@ \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c,fragile] - \frametitle{Scala 2.13.1} - - \begin{lstlisting}[language={},numbers=none, - basicstyle=\ttfamily\small,xleftmargin=-2mm] - $ scala - - Welcome to Scala 2.13.1 (Java HotSpot(TM) - 64-Bit Server VM, Java 9). Type in expressions - for evaluation. Or try :help. - - scala> - \end{lstlisting}%$ - \bigskip\bigskip - - With older versions you will get strange results with my reference implementation. - - \end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c,fragile] -\frametitle{Reference Implementation} - -Keep your implementation and my reference implementation separate.\bigskip - - \begin{lstlisting}[language={},numbers=none, - basicstyle=\ttfamily\small,xleftmargin=-2mm] - $ scala -cp collatz.jar - - scala> CW6a.collatz(6) - res0: Long = 8 - - - scala> import CW6a._ - scala> collatz(9) - res1: Long = 19 - \end{lstlisting}%$ +\begin{frame}[t,fragile] +\frametitle{For-Comprehensions} -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t] - \frametitle{Preliminary Part 7} - - \Large - \[ - \texttt{overlap}(d_1, d_2) = \frac{d_1 \cdot d_2}{max(d_1^2, d_2^2)} - \]\bigskip - - \large - \quad{}\;where \;$d_1^2$\; means \;$d_1 \cdot d_1$\; and so on -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c] - \frametitle{Discussion Forum} - - \large - ``Since we can't use \code{var}s I was wondering if we could use a stack?'' - \bigskip\bigskip\bigskip\bigskip +%\small +\begin{lstlisting}[language=Scala,numbers=none] +for (n <- List(1, 2, 3, 4, 5)) yield n * n +\end{lstlisting} - \small - My \pcode{collatz} and \pcode{collatz_max} functions are 4 loc each. -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{textblock}{5}(2,6) +\includegraphics[scale=0.3]{../pics/fun.png} +\end{textblock} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t] - \frametitle{Email: Hate 'val'} - - \mbox{}\\[-22mm]\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}{<>}\\ - \end{bubble} - \end{center} - -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c] +\begin{textblock}{5}(9,6) +\includegraphics[scale=0.3]{../pics/fun.png} +\end{textblock} - \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<>}}\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:} - \raisebox{-12mm}{\includegraphics[scale=0.08]{../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 = - ...<>... && !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} - -\only<2>{ -\begin{textblock}{6}(0.3,11.8) - \begin{bubble}[3.1cm] - \textbf{Me:} - \raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}} - \end{bubble} -\end{textblock}} - -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[c] -\frametitle{Assignments} - -Don't change any names or types in the templates!\bigskip - -Avoid at all costs: - -\begin{itemize} -\item \code{var} -\item \code{return} -\item \texttt{ListBuffer} -\item \texttt{mutable} -\item \texttt{.par} -\end{itemize}\bigskip\bigskip - -I cannot think of a good reason to use stacks. -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[t] -\frametitle{For-Comprehensions Again} +\frametitle{For-Comprehensions} \begin{center} \begin{tikzpicture}[scale=1,