# HG changeset patch # User Christian Urban # Date 1565688200 -3600 # Node ID eb1b4ad23941b20f33fa887bcfb621f758f23913 # Parent 8980686aa2e8307a9cf5cbb9a1163f1339d29bde updated diff -r 8980686aa2e8 -r eb1b4ad23941 cws/cw04.pdf Binary file cws/cw04.pdf has changed diff -r 8980686aa2e8 -r eb1b4ad23941 cws/cw04.tex --- a/cws/cw04.tex Sun Aug 11 21:01:49 2019 +0100 +++ b/cws/cw04.tex Tue Aug 13 10:23:20 2019 +0100 @@ -96,6 +96,12 @@ \section*{Coursework 9 (Scala)} +\mbox{}\hfill\textit{``[Google’s MapReduce] abstraction is inspired by the}\\ +\mbox{}\hfill\textit{map and reduce primitives present in Lisp and many}\\ +\mbox{}\hfill\textit{other functional language.''}\smallskip\\ +\mbox{}\hfill\textit{ --- Dean and Ghemawat, who designed this concept at Google}\bigskip + +\noindent This coursework is worth 10\%. It is about a regular expression matcher and the shunting yard algorithm by Dijkstra. The first part is due on \cwNINE{} at 11pm; the second, more advanced part, is due on diff -r 8980686aa2e8 -r eb1b4ad23941 handouts/pep-ho.pdf Binary file handouts/pep-ho.pdf has changed diff -r 8980686aa2e8 -r eb1b4ad23941 handouts/pep-ho.tex --- a/handouts/pep-ho.tex Sun Aug 11 21:01:49 2019 +0100 +++ b/handouts/pep-ho.tex Tue Aug 13 10:23:20 2019 +0100 @@ -337,29 +337,33 @@ \end{boxedminipage} \end{figure} -But remember this easy parallelisation of code requires that we -have no state in our programs\ldots{}that is no counters like -\texttt{i} in \texttt{for}-loops. You might then ask, how do I write -loops without such counters? Well, teaching you that this is possible is -one of the main points of the Scala-part in PEP. I can assure you it is -possible, but you have to get your head around it. Once you have -mastered this, it will be fun to have no state in your programs (a side -product is that it much easier to debug state-less code and also more -often than not easier to understand). So have fun with -Scala!\footnote{If you are still not convinced about the function -programming ``thing'', there are a few more arguments: a lot of research -in programming languages happens to take place in functional programming -languages. This has resulted in ultra-useful features such as -pattern-matching, strong type-systems, laziness, implicits, algebraic -datatypes to name a few. Imperative languages seem to often lag behind -in adopting them: I know, for example, that Java will at some point in -the future support pattern-matching, which has been used for example -in SML for at -least 40(!) years. See +But remember this easy parallelisation of code requires that we have no +state in our programs\ldots{}that is no counters like \texttt{i} in +\texttt{for}-loops. You might then ask, how do I write loops without +such counters? Well, teaching you that this is possible is one of the +main points of the Scala-part in PEP. I can assure you it is possible, +but you have to get your head around it. Once you have mastered this, it +will be fun to have no state in your programs (a side product is that it +much easier to debug state-less code and also more often than not easier +to understand). So have fun with Scala!\footnote{If you are still not +convinced about the function programming ``thing'', there are a few more +arguments: a lot of research in programming languages happens to take +place in functional programming languages. This has resulted in +ultra-useful features such as pattern-matching, strong type-systems, +laziness, implicits, algebraic datatypes to name a few. Imperative +languages seem to often lag behind in adopting them: I know, for +example, that Java will at some point in the future support +pattern-matching, which has been used for example in SML for at least +40(!) years. See \url{http://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html}. -Also Rust, a C-like programming language that has been developed since -2010 and is gaining quite some interest, borrows many ideas from -functional programming from yesteryear.} +Automatic garbage collection was included in Java in 1995; the +functional language LISP had this already in 1958. Generics were added +to Java 5 in 2004; the functional language SML had it since 1990. +Higher-order functions were added to C$\sharp$ in 2007, to Java 8 in +2014; again LISP had them since 1958. Also Rust, a C-like programming +language that has been developed since 2010 and is gaining quite some +interest, borrows many ideas from functional programming from +yesteryear.} \subsection*{The Very Basics} diff -r 8980686aa2e8 -r eb1b4ad23941 slides-old.sty --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slides-old.sty Tue Aug 13 10:23:20 2019 +0100 @@ -0,0 +1,88 @@ +\usepackage[absolute,overlay]{textpos} +\usepackage{xcolor} +\usepackage{fontspec} +\usepackage[sc]{mathpazo} +\usefonttheme{serif} +\defaultfontfeatures{Ligatures=TeX} +\defaultfontfeatures{Mapping=tex-text} +\setromanfont{Hoefler Text} +\setmonofont[Scale=.88]{Consolas} +\newfontfamily{\consolas}{Consolas} + +\definecolor{darkblue}{rgb}{0,0,0.6} +\hypersetup{colorlinks=true} +\hypersetup{linkcolor=darkblue} +\hypersetup{urlcolor=darkblue} + +\newcommand{\tttext}[1]{{\consolas{#1}}} + +\newcommand{\ZERO}{\mbox{\bf 0}} +\newcommand{\ONE}{\mbox{\bf 1}} +\newcommand{\Der}{\textit{Der}} +\newcommand{\der}{\textit{der}} +\newcommand{\Ders}{\textit{Ders}} +\newcommand{\ders}{\textit{ders}} +\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% +\newcommand{\slidecaption}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Frametitles + +\setbeamerfont{frametitle}{size={\LARGE}} +\setbeamerfont{frametitle}{family={\fontspec{Hoefler Text Black}}} +\setbeamercolor{frametitle}{fg=ProcessBlue,bg=white} + +\setbeamertemplate{frametitle}{% +\vskip 2mm % distance from the top margin +\hskip -3mm % distance from left margin +\vbox{% +\begin{minipage}{1.05\textwidth}% +\centering% +\begin{tabular}{@{}c@{}}% +\insertframetitle% +\end{tabular}% +\end{minipage}\vspace{-10pt}}% +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Foot +% +\setbeamertemplate{navigation symbols}{} +\usefoottemplate{% +\vbox{% + \tinyline{% + \tiny\hfill\textcolor{gray!50}{\slidecaption{} -- + p.~\insertframenumber/\inserttotalframenumber}}}% +} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\beamertemplateballitem +\setlength\leftmargini{2mm} +\setlength\leftmarginii{0.6cm} +\setlength\leftmarginiii{1.5cm} +\setbeamertemplate{itemize/enumerate body end}{\vspace{-2mm}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% blocks +%\definecolor{cream}{rgb}{1,1,.65} +\definecolor{cream}{rgb}{1,1,.8} +\setbeamerfont{block title}{size=\normalsize} +\setbeamercolor{block title}{fg=black,bg=cream} +\setbeamercolor{block body}{fg=black,bg=cream} + +\setbeamertemplate{blocks}[rounded][shadow=true] + +\setbeamercolor{boxcolor}{fg=black,bg=cream} + +\mode + + + + + + + diff -r 8980686aa2e8 -r eb1b4ad23941 slides.sty --- a/slides.sty Sun Aug 11 21:01:49 2019 +0100 +++ b/slides.sty Tue Aug 13 10:23:20 2019 +0100 @@ -1,27 +1,48 @@ \usepackage[absolute,overlay]{textpos} \usepackage{xcolor} -\usepackage{fontspec} +\usepackage[no-math]{fontspec} + +%%%%% CODE FONT +%\setmonofont[Scale=.95]{Consolas} +\setmonofont[Scale=.88]{Consolas} +\newfontfamily{\consolas}{Consolas} + +%%%%% MATHFONT \usepackage[sc]{mathpazo} +%\usepackage{fourier} +%\usepackage{mathspec} +%\usepackage[varg]{txfonts} +%\usepackage{mathpple} + +%%%%% MAIN TEXT FONT +\setromanfont{Cronos Pro} +%\setbeamerfont{normal text}{family={\fontspec{Cronos Pro}}} +%\setbeamerfont{normal text}{family={\fontspec{Hoefler Text}}} +%\setromanfont{Cronos Pro} +%\setromanfont{Hoefler Text} \usefonttheme{serif} \defaultfontfeatures{Ligatures=TeX} \defaultfontfeatures{Mapping=tex-text} -\setromanfont{Hoefler Text} -\setmonofont[Scale=.88]{Consolas} -\newfontfamily{\consolas}{Consolas} + + +%%%% Colours \definecolor{darkblue}{rgb}{0,0,0.6} \hypersetup{colorlinks=true} \hypersetup{linkcolor=darkblue} \hypersetup{urlcolor=darkblue} +\hfuzz=320pt + + \newcommand{\tttext}[1]{{\consolas{#1}}} -\newcommand{\ZERO}{\mbox{\bf 0}} -\newcommand{\ONE}{\mbox{\bf 1}} -\newcommand{\Der}{\textit{Der}} -\newcommand{\der}{\textit{der}} -\newcommand{\Ders}{\textit{Ders}} -\newcommand{\ders}{\textit{ders}} +\newcommand{\ZERO}{\mathit{\bf 0}} +\newcommand{\ONE}{\mathit{\bf 1}} +\newcommand{\Der}{\mathit{Der}} +\newcommand{\der}{\mathit{der}} +\newcommand{\Ders}{\mathit{Ders}} +\newcommand{\ders}{\mathit{ders}} \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% \newcommand{\slidecaption}{} @@ -29,7 +50,8 @@ % Frametitles \setbeamerfont{frametitle}{size={\LARGE}} -\setbeamerfont{frametitle}{family={\fontspec{Hoefler Text Black}}} +%\setbeamerfont{frametitle}{family={\fontspec{Hoefler Text Black}}} +\setbeamerfont{frametitle}{family={\fontspec{Cronos Pro Bold Caption}}} \setbeamercolor{frametitle}{fg=ProcessBlue,bg=white} \setbeamertemplate{frametitle}{% @@ -38,9 +60,9 @@ \vbox{% \begin{minipage}{1.05\textwidth}% \centering% -\begin{tabular}{@{}c@{}}% +%\begin{tabular}{@{}c@{}}% \insertframetitle% -\end{tabular}% +%\end{tabular}% \end{minipage}\vspace{-10pt}}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%