slides/slides04.tex
changeset 217 e689375abcc1
parent 158 94b11ac19b41
child 222 e52cc402caee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/slides/slides04.tex	Fri Nov 23 01:52:37 2018 +0000
@@ -0,0 +1,326 @@
+\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{filecontents}{re3a.data}
+1 0.00003
+500001 0.22527
+1000001 0.62752
+1500001 0.88485
+2000001 1.39815
+2500001 1.68619
+3000001 1.94957
+3500001 2.15878
+4000001 2.59918
+4500001 5.90679
+5000001 13.11295
+5500001 19.15376
+6000001 40.16373
+\end{filecontents}
+\begin{filecontents}{re-python2.data}
+1 0.033
+5 0.036
+10 0.034
+15 0.036
+18 0.059
+19 0.084
+20 0.141
+21 0.248
+22 0.485
+23 0.878
+24 1.71
+25 3.40
+26 7.08
+27 14.12
+28 26.69
+\end{filecontents}
+
+\begin{filecontents}{re-java.data}
+5  0.00298
+10  0.00418
+15  0.00996
+16  0.01710
+17  0.03492
+18  0.03303
+19  0.05084
+20  0.10177
+21  0.19960
+22  0.41159
+23  0.82234
+24  1.70251
+25  3.36112
+26  6.63998
+27  13.35120
+28  29.81185
+\end{filecontents}
+
+\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\\
+    Scala Office & \\
+    Hours: &  Thursdays 11 -- 13\\
+  \end{tabular}
+  \end{center}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+
+\begin{textblock}{6}(0.5,0.5)
+\begin{bubble}[11.5cm]
+\footnotesize
+\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
+import java.util.concurrent._
+import java.util.concurrent.atomic._
+
+  def collatz(input:Int){
+          CollatzConjecture(input);
+          println(count.get());
+      }
+      def collatz_max(input:Int){
+          val List = new Array[Int](input)
+            for (i <- 0 to input-1){
+                CollaĵConjecture(i);
+                List(i)=count.get();
+                count.set(0);
+            }
+            val max = new AtomicInteger();
+            max.set(List(0));
+            val index = new AtomicInteger();
+            index.set(1);
+ 
+\end{lstlisting}
+\end{bubble}
+\end{textblock}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+
+\begin{textblock}{6}(0.5,0.5)
+\begin{bubble}[11.5cm]
+\footnotesize
+\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
+             for(i<-0 to input-1){
+                val temp :Int=max.get();
+                if (temp < List(i)){
+                    max.set(List(i));
+                    index.set(i);
+                }
+            }
+            println("("+max.get() +","+ index.get()+ ")");
+      }
+
+      def CollatzConjecture(n: Long): Long = {
+        count.incrementAndGet();
+        if (n <= 1)
+            1
+        else if (n\%2 ==0)
+            CollatzConjecture(n/2);
+            else
+               CollatzConjecture((3*n)+1);
+   }
+ }
+\end{lstlisting}
+\end{bubble}
+\end{textblock}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+  \frametitle{CW3 (1 Part): Regexes}
+  
+\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 8},  
+    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,fragile]
+\frametitle{\alert{Questions?}}
+
+{\tiny
+\begin{verbatim}
+                               *
+                              * *
+                             *   *
+                            * * * *
+                           *       *
+                          * *     * *
+                         *   *   *   *
+                        * * * * * * * *
+                       *               *
+                      * *             * *
+                     *   *           *   *
+                    * * * *         * * * *
+                   *       *       *       *
+                  * *     * *     * *     * *
+                 *   *   *   *   *   *   *   *
+                * * * * * * * * * * * * * * * *
+               *                               *
+              * *                             * *
+             *   *                           *   *
+            * * * *                         * * * *
+           *       *                       *       *
+          * *     * *                     * *     * *
+         *   *   *   *                   *   *   *   *
+        * * * * * * * *                 * * * * * * * *
+       *               *               *               *
+      * *             * *             * *             * *
+     *   *           *   *           *   *           *   *
+    * * * *         * * * *         * * * *         * * * *
+   *       *       *       *       *       *       *       *
+  * *     * *     * *     * *     * *     * *     * *     * *
+ *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+\end{verbatim}}
+
+
+\begin{textblock}{6}(8.5,3.5)
+\begin{bubble}[5cm]
+\footnotesize
+\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
+++++++++[>+>++++<<-]>++>>
++<[-[>>+<<-]+>>]>+[-<<<[-
+>[+[-]+>++>>>-<<]<[<]>>++
+++++[<<+++++>>-]+<<++.[-]
+<<]>.>+[>>]>+]
+\end{lstlisting}
+\end{bubble}
+\end{textblock}
+  
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
+
+\begin{frame}[c]
+\frametitle{Marks for CW6 (Part 1 + 2)}
+
+Raw marks:
+
+\begin{itemize}
+\item 6\%: 154 students
+\item 5\%: 66
+\item 4\%: 18
+\item 3\%: 13
+\item 2\%: 2
+\item 1\%: 1
+\item 0\%: 21 
+\end{itemize}  
+\end{frame}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\end{document}
+
+
+\end{document}
+
+%%% Local Variables:  
+%%% mode: latex
+%%% TeX-master: t
+%%% End: 
+