--- a/slides/slides02.tex Mon Nov 11 13:24:12 2019 +0000
+++ b/slides/slides02.tex Mon Nov 11 14:04:22 2019 +0000
@@ -107,98 +107,191 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
-\frametitle{Assignments}
-
-Don't change anything with the templates!\bigskip
-
-Avoid at all costs:
+ \frametitle{Discussion Forum}
+
+ \large
+ ``Since we cant use \code{var}s I was wondering if we could use a stack?''
+ \bigskip\bigskip\bigskip\bigskip
-\begin{itemize}
-\item \texttt{var}
-\item \texttt{return}
-\item \texttt{ListBuffer}
-\item \texttt{mutable}
-\item \texttt{.par}
-\end{itemize}\pause\bigskip
-
-
-\mbox{}\hfill\textit{``Scala --- \underline{S}lowly \underline{c}ompiled
-\underline{a}cademic \underline{la}nguage''}\smallskip\\
-\mbox{}\hfill\textit{ --- a joke(?) found on Twitter}\bigskip
+ \small
+ My \pcode{collatz} and \pcode{collatz_max} functions are 4 loc each.
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
-\frametitle{Email: Hate 'val'}
+ \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}{<<deleted>>}\\
+ \end{bubble}
+ \end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
-\mbox{}\\[-25mm]\mbox{}
+ \mbox{}\\[-25mm]\mbox{}
\begin{center}
\begin{bubble}[10.5cm]
- Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
-
- Hello Mr Urban,\medskip\\
+ Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
- 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>>}\\
+ \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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\firstcircle{(0,0) circle (1.4cm)}
-\def\secondcircle{(0:2cm) circle (1.4cm)}
-\colorlet{circle edge}{blue!50}
-\colorlet{circle area}{blue!20}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\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\\
-\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
- outline/.style={draw=circle edge, thick}}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Par: Intersections}
+ \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}(1,2)
-\begin{tikzpicture}
- \draw[outline] \firstcircle node {$A$};
- \node[anchor=south] at (current bounding box.north)
- {$A = \{1,2,3,\ldots,1000\}$};
-\end{tikzpicture}
+\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}
-\begin{textblock}{6}(8,2)
-\begin{tikzpicture}
- \draw[outline] \secondcircle node {$B$};
- \node[anchor=south] at (current bounding box.north)
- {$B = \{1,5,9,13,\ldots,997\}$};
-\end{tikzpicture}
+\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 =
+ ...<<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}
-\begin{textblock}{6}(3.3,9)
-\begin{tikzpicture}
- \begin{scope}
- \clip \firstcircle;
- \fill[filled] \secondcircle;
- \end{scope}
- \draw[outline] \firstcircle node {$A$};
- \draw[outline] \secondcircle node {$B$};
- \node[anchor=north] at (current bounding box.south)
- {How many elements are in $A \cap B$?};
-\end{tikzpicture}
-\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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -285,37 +378,23 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
-\frametitle{Why Scala? No null!}
-
-
-\begin{itemize}
-\item \large {\bf You can avoid \textcolor{blue}{\texttt{null}}}:
-\end{itemize}
+\frametitle{Option Type}
-\begin{textblock}{6}(1,5)
- \begin{bubble}[10.5cm]\small
- ``I call it my billion-dollar mistake. It was the invention of
- the null reference in 1965. At that time, I was designing the
- first comprehensive type system for references in an object
- oriented language (ALGOL W). My goal was to ensure that all use
- of references should be absolutely safe, with checking performed
- automatically by the compiler. But I couldn't resist the
- temptation to put in a null reference, simply because it was so
- easy to implement. This has led to innumerable errors,
- vulnerabilities, and system crashes, which have probably caused
- a billion dollars of pain and damage in the last forty years.''
- \hfill Sir Tony (Hoare)
-\end{bubble}
-\end{textblock}
-
-\begin{textblock}{5}(12.5,1.9)
-\includegraphics[scale=0.05]{../pics/hoare.jpg}\\
-\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[t]
+\frametitle{Higher-Order Functions}
+
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}