diff -r 029e2862bb4e -r b84ea52bfd8f slides/slides02.tex --- a/slides/slides02.tex Tue Nov 12 00:41:00 2019 +0000 +++ b/slides/slides02.tex Tue Nov 12 10:47:27 2019 +0000 @@ -441,7 +441,7 @@ \end{lstlisting} \end{onlyenv}\bigskip\bigskip\bigskip -in the Scala code it is clear from the type I have to deal +in the Scala code it is clear from the type I that have to deal with the \pcode{None}-case; no JavaDoc needed \end{frame} @@ -574,9 +574,24 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c,fragile] -\frametitle{Recursion} +\frametitle{Pattern Matching} + +\ldots on pairs:\bigskip +\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm] +def fizz_buzz(n: Int) : String = + (n % 3, n % 5) match { + case (0, 0) => "fizz buzz" + case (0, _) => "fizz" + case (_, 0) => "buzz" + case _ => n.toString + } +\end{lstlisting} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] +\frametitle{Recursion} \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm] def fib(n: Int) : Int = { @@ -646,11 +661,84 @@ \begin{textblock}{14}(2,11.4) \large\bf{}Mind-Blowing Programming Languages:\\ - \centering PHP + \centering PHP \textcolor{gray}{(7.0)} \end{textblock} \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}