updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Fri, 06 Nov 2020 01:07:26 +0000
changeset 352 97bcf8efe4e0
parent 351 591b9005157e
child 353 bb6074814a73
updated
handouts/pep-ho.pdf
handouts/pep-ho.tex
main_templates3/re.scala
main_testing1/drumb_test.sh
main_testing2/danube_test.sh
main_testing3/re_test.sh
main_testing4/knight_test.sh
main_testing5/bf_test.sh
main_testing5/bfc_test.sh
pre_testing1/collatz_test.sh
pre_testing2/docdiff_test.sh
pre_testing3/postfix_test.sh
slides.sty
slides/slides01.pdf
slides/slides01.tex
slides/slides02.pdf
Binary file handouts/pep-ho.pdf has changed
--- a/handouts/pep-ho.tex	Wed Nov 04 15:35:31 2020 +0000
+++ b/handouts/pep-ho.tex	Fri Nov 06 01:07:26 2020 +0000
@@ -7,8 +7,10 @@
 \usepackage{marvosym}
 \usepackage{boxedminipage}
 
+\lstset{escapeinside={/*!}{!*/}}
+\newcommand{\annotation}[1]{\hfill\footnotesize{}#1}
 
-
+\usepackage{menukeys}
 
 
 %cheat sheet
@@ -1095,7 +1097,7 @@
 all aggregate functions are pre-defined and often you have to write your
 own recursive function for this.
 
-\subsection*{Always Produce a Result! No Exceptions!}
+%\subsection*{Always Produce a Result! No Exceptions!}
 %
 %Function should always produce a value. Exception is not thrown.
 %Whenever there is a possibility of non-value result (exception, void,
@@ -1104,7 +1106,7 @@
 %
 %Option[T]
 
-TBD
+%TBD
 
 
 \subsection*{Higher-Order Functions}
@@ -1623,63 +1625,71 @@
 \subsection*{Scala Syntax for Java Developers}
 
 Scala compiles to the JVM, like the Java language. Because of this,
-it can re-use many libraries.
+it can re-use many libraries. Here are a few hints how some Java code
+tranlsates to Scala code:\bigskip
 
+\noindent
+Variable declaration:
 \begin{lstlisting}[language=Java]
-Drink coke = getCoke();
+Drink coke = getCoke();/*!\annotation{Java}!*/
 \end{lstlisting}
 
 \begin{lstlisting}[language=Scala]
-val coke : Drink = getCoke()
+val coke : Drink = getCoke()/*!\annotation{Scala}!*/
 \end{lstlisting}
 
+\noindent
 Unit means void:
 
 \begin{lstlisting}[language=Java]
-public void output(String s) {
+public void output(String s) {/*!\annotation{Java}!*/
   System.out.println(s);
 }
 \end{lstlisting}
 
 \begin{lstlisting}[language=Scala]
-def output(s: String): Unit = println(s)
+def output(s: String): Unit = println(s)/*!\annotation{Scala}!*/
 \end{lstlisting}
 
-
+\noindent
 Type for list of Strings:
 
 \begin{lstlisting}[language=Java]
-List<String>
+List<String>/*!\annotation{Java}!*/
 \end{lstlisting}
 
 \begin{lstlisting}[language=Scala]
-List[String]
+List[String]/*!\annotation{Scala}!*/
 \end{lstlisting}
 
+\noindent
 String interpolations
 
 \begin{lstlisting}[language=Java]
-System.out.println("Hello, "+ firstName + " "+ lastName + "!");
+System.out.println("Hello, "+ first + " "+ last + "!");
+/*!\annotation{Java}!*/
 \end{lstlisting}
 
 \begin{lstlisting}[language=Scala]
-println(s"Hello, $firstName $lastName!")
+println(s"Hello, $first $last!")/*!\annotation{Scala}!*/
 \end{lstlisting}
 
-
-Java provides syntactic sugar when constructing lambda functions:
+\noindent
+Java provides syntactic some sugar when constructing anonymous functions:
 
 \begin{lstlisting}[language=Java]
 list.foreach(item -> System.out.println("* " + item));
+/*!\annotation{Java}!*/
 \end{lstlisting}
 
-In Scala, we use the => symbol with anonymous functions:
+\noindent
+In Scala, we use the \code{=>} symbol:
 
 \begin{lstlisting}[language=Scala]
-list.foreach(item => println(s"* $item"))
-\end{lstlisting}
+list.foreach(item => println(s"* $item"))/*!\annotation{Scala}!*/
+\end{lstlisting}%$
 
-new / vs case classes
+%%new / vs case classes
 
 
 \subsection*{More Info}
--- a/main_templates3/re.scala	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_templates3/re.scala	Fri Nov 06 01:07:26 2020 +0000
@@ -39,7 +39,7 @@
   def ~ (r: String) = SEQ(s, r)
 }
 
-// (5) Complete the function nullable according to
+// (1) Complete the function nullable according to
 // the definition given in the coursework; this 
 // function checks whether a regular expression
 // can match the empty string and Returns a boolean
@@ -48,7 +48,7 @@
 def nullable (r: Rexp) : Boolean = ???
 
 
-// (6) Complete the function der according to
+// (2) Complete the function der according to
 // the definition given in the coursework; this
 // function calculates the derivative of a 
 // regular expression w.r.t. a character.
@@ -56,7 +56,7 @@
 def der (c: Char, r: Rexp) : Rexp = ???
 
 
-// (7) Complete the simp function according to
+// (3) Complete the simp function according to
 // the specification given in the coursework; this
 // function simplifies a regular expression from
 // the inside out, like you would simplify arithmetic 
@@ -66,7 +66,7 @@
 def simp(r: Rexp) : Rexp = ???
 
 
-// (8) Complete the two functions below; the first 
+// (4) Complete the two functions below; the first 
 // calculates the derivative w.r.t. a string; the second
 // is the regular expression matcher taking a regular
 // expression and a string and checks whether the
@@ -77,7 +77,7 @@
 def matcher(r: Rexp, s: String): Boolean = ???
 
 
-// (9) Complete the size function for regular
+// (5) Complete the size function for regular
 // expressions according to the specification 
 // given in the coursework.
 
--- a/main_testing1/drumb_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing1/drumb_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -35,7 +35,7 @@
 
 if (scala_compile drumb.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN drumb.scala" >> $out
@@ -56,7 +56,7 @@
 	echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out
 	tsts=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts=$(( 0 )) 
     fi
 fi    
--- a/main_testing2/danube_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing2/danube_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -38,7 +38,7 @@
 
 if (scala_compile danube.scala)
 then
-    echo "  --> success" >> $out
+    echo "  --> passed" >> $out
     tsts=$(( 0 ))
 else
     echo "  --> SCALA DID NOT RUN danube.scala" >> $out
@@ -57,7 +57,7 @@
 	echo "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out
 	tsts=$(( 1 ))
     else
-	echo "  --> success" >> $out
+	echo "  --> passed" >> $out
 	tsts=$(( 0 )) 
     fi
 fi
--- a/main_testing3/re_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing3/re_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -36,7 +36,7 @@
 
 if (scala_compile re.scala)
 then
-    echo -e "  --> yes" >> $out
+    echo -e "  --> passed" >> $out
     tsts=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN RE.SCALA\n" >> $out
@@ -55,7 +55,7 @@
 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out 
 	tsts=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts=$(( 0 )) 
     fi
 fi
--- a/main_testing4/knight_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing4/knight_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -45,7 +45,7 @@
 
 if (scala_compile knight1.scala)
 then
-    echo -e "  --> success " >> $out
+    echo -e "  --> passed" >> $out
     tsts1=$(( 0 ))
   else
     echo -e "  --> SCALA DID NOT RUN KNIGHT1.SCALA\n" >> $out
@@ -64,7 +64,7 @@
 	echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
 	tsts1=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts1=$(( 0 )) 
     fi
 fi    
@@ -176,7 +176,7 @@
 
 if (scala_compile knight2.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts2=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN KNIGHT2.SCALA\n" >> $out  
@@ -196,7 +196,7 @@
 	echo -e "  --> Fail (make triple-sure your program conforms to the required format)" >> $out    
 	tsts2=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts2=$(( 0 )) 
     fi
 fi
@@ -263,7 +263,7 @@
 
 if (scala_compile knight3.scala)
 then
-    echo "  --> success" >> $out
+    echo "  --> passed" >> $out
     tsts3=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN KNIGHT3.SCALA\n" >> $out  
@@ -281,7 +281,7 @@
 	echo "  --> Fail (make triple-sure your program conforms to the required format)xsxs" >> $out
 	tsts3=$(( 1 ))
     else
-	echo "  --> success" >> $out
+	echo "  --> passed" >> $out
 	tsts3=$(( 0 )) 
     fi
 fi
--- a/main_testing5/bf_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing5/bf_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -34,7 +34,7 @@
 
 if (scala_compile bf.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts1=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN BF.SCALA\n" >> $out
@@ -54,7 +54,7 @@
 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
 	tsts1=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts1=$(( 0 )) 
     fi
 fi
--- a/main_testing5/bfc_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/main_testing5/bfc_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -34,10 +34,10 @@
 
 if (scala_compile bfc.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts1=$(( 0 ))
 else
-    echo -e "  -->   --> SCALA DID NOT RUN BFC.SCALA\n" >> $out
+    echo -e "  --> SCALA DID NOT RUN BFC.SCALA\n" >> $out
     tsts1=$(( 1 )) 
 fi
 
@@ -53,7 +53,7 @@
 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
 	tsts1=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts1=$(( 0 )) 
     fi
 fi
--- a/pre_testing1/collatz_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/pre_testing1/collatz_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -37,7 +37,7 @@
 
 if (scala_compile collatz.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN collatz.scala\n" >> $out
@@ -57,7 +57,7 @@
       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
       tsts=$(( 1 ))
    else
-      echo -e "  --> success" >> $out
+      echo -e "  --> passed" >> $out
       tsts=$(( 0 )) 
    fi
 fi    
--- a/pre_testing2/docdiff_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/pre_testing2/docdiff_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -38,7 +38,7 @@
 
 if (scala_compile docdiff.scala)
 then
-    echo -e "  --> success" >> $out
+    echo -e "  --> passed" >> $out
     tsts=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN docdiff.scala\n" >> $out
@@ -57,7 +57,7 @@
       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
       tsts=$(( 1 ))
    else
-      echo -e "  --> success" >> $out
+      echo -e "  --> passed" >> $out
       tsts=$(( 0 )) 
    fi
 fi
--- a/pre_testing3/postfix_test.sh	Wed Nov 04 15:35:31 2020 +0000
+++ b/pre_testing3/postfix_test.sh	Fri Nov 06 01:07:26 2020 +0000
@@ -35,7 +35,7 @@
 
 if (scala_compile postfix.scala)
 then
-    echo -e "  --> yes" >> $out
+    echo -e "  --> passed" >> $out
     tsts=$(( 0 ))
   else
     echo -e "  --> SCALA DID NOT RUN postfix.scala\n" >> $out
@@ -54,7 +54,7 @@
 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out 
 	tsts=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts=$(( 0 )) 
     fi
 fi
@@ -107,7 +107,7 @@
 
 if (scala_compile postfix2.scala)
 then
-    echo -e "  --> yes" >> $out
+    echo -e "  --> passed" >> $out
     tsts1=$(( 0 ))
 else
     echo -e "  --> SCALA DID NOT RUN postfix2.scala\n" >> $out
@@ -126,7 +126,7 @@
 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out 
 	tsts1=$(( 1 ))
     else
-	echo -e "  --> success" >> $out
+	echo -e "  --> passed" >> $out
 	tsts1=$(( 0 )) 
     fi
 fi
--- a/slides.sty	Wed Nov 04 15:35:31 2020 +0000
+++ b/slides.sty	Fri Nov 06 01:07:26 2020 +0000
@@ -24,6 +24,8 @@
 \defaultfontfeatures{Ligatures=TeX}
 \defaultfontfeatures{Mapping=tex-text}
 
+%% for recording slides
+\setbeamersize{text margin right=5cm} % <- like this
 
 %%%% Colours
 
@@ -82,7 +84,10 @@
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\beamertemplateballitem
+%%\beamertemplateballitem
+\setbeamertemplate{itemize item}[ball]
+\setbeamertemplate{itemize subitem}[ball]
+\setbeamertemplate{itemize subsubitem}[ball]
 \setlength\leftmargini{2mm}
 \setlength\leftmarginii{0.6cm}
 \setlength\leftmarginiii{1.5cm}
Binary file slides/slides01.pdf has changed
--- a/slides/slides01.tex	Wed Nov 04 15:35:31 2020 +0000
+++ b/slides/slides01.tex	Fri Nov 06 01:07:26 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{../slides}
 \usepackage{../graphics}
 \usepackage{../langs}
@@ -49,6 +49,14 @@
 % processors in the future / Ahmdahl law
 % https://www.youtube.com/watch?v=_9mzmvhwMqw
 
+\setbeamertemplate{itemize items}{$\bullet$}
+\setbeamertemplate{itemize subitem}{$\bullet$}
+\setbeamertemplate{itemize subsubitem}{$\bullet$}
+
+\usepackage{tcolorbox}
+\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
+\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
+\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
 
 \begin{document}
 
@@ -87,7 +95,7 @@
 \begin{frame}[c]
 \frametitle{Why Scala?}
 
-\begin{textblock}{6}(3,4)
+\begin{textblock}{6}(3,3)
 \begin{tabular}{l}
 \mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
 \includegraphics[scale=0.30]{../pics/linked.png}\\
@@ -98,7 +106,7 @@
 \end{tabular}
 \end{textblock}
 
-\begin{textblock}{6}(9,4)
+\begin{textblock}{6}(9,3)
 \begin{tabular}{l}
 \includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
 \includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
@@ -109,19 +117,27 @@
 \end{textblock}
 
 
-\begin{textblock}{6}(2,12)
-\begin{bubble}[9.4cm]
-  \small
-  developed since 2004 by Martin Odersky
-  (he was behind Generic Java which was included in Java 5
-  \ldots I am using Scala since maybe 2008?)
-\end{bubble}
-\end{textblock}
+\begin{textblock}{12}(2,11)
+  \footnotesize
+  \begin{mybox3}{A former student working now at Quantexa:}\it
+    ``I am a former student. I graduated last year. I got my dream job
+    as a backend Scala developer. Most of the Scala I know is from PEP
+    2018/19. My interviewers said they expect code of a lesser quality
+    even from people with one year of experience.''
+\end{mybox3}
+\end{textblock}  
 
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 
-
+%\begin{textblock}{6}(2,12)
+%\begin{bubble}[9.4cm]
+%  \small
+%  developed since 2004 by Martin Odersky
+%  (he was behind Generic Java which was included in Java 5
+%  \ldots I am using Scala since maybe 2008?)
+%\end{bubble}
+%\end{textblock}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
@@ -131,9 +147,11 @@
 \item compiles to the JVM\\
   \textcolor{gray}{(also JavaScript, native X86 in the works)}\medskip
 \item integrates seamlessly with Java\medskip
-\item combines \underline{\bf functional} and {\bf object-oriented} programming\bigskip
-\item it is a bit on the ``theory'' / ``mathematical'' side\\
-  \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
+\item combines \underline{\bf functional} and {\bf object-oriented} programming\medskip
+
+\item no pointers, no null
+%\item it is a bit on the ``theory'' / ``mathematical'' side\\
+%  \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
   
 \item often one can write very concise and elegant code
 \end{itemize}\bigskip\medskip  
Binary file slides/slides02.pdf has changed