diff -r 57b3ae5ba5e2 -r 6d9c960a2b26 slides/slides10.tex --- a/slides/slides10.tex Wed Dec 04 14:39:32 2019 +0000 +++ b/slides/slides10.tex Sat Dec 07 00:57:23 2019 +0000 @@ -1,3 +1,4 @@ +% !TEX program = xelatex \documentclass[dvipsnames,14pt,t]{beamer} \usepackage{../slides} \usepackage{../langs} @@ -50,20 +51,62 @@ \normalsize \begin{center} \begin{tabular}{ll} - Email: & christian.urban at kcl.ac.uk\\ - Office: & N7.07 (North Wing, Bush House)\\ - Slides: & KEATS (also home work is there)\\ + Email: & christian.urban at kcl.ac.uk\\ + Office Hours: & Thursdays 12 -- 14\\ + Location: & N7.07 (North Wing, Bush House)\\ + Slides \& Progs: & KEATS (also homework is there)\\ \end{tabular} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] + + +\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm] +def fact(n: Int) : Int = { + if (n == 0) 1 else n * fact(n - 1) +} + + +def factC(n: Int, ret: Int => Int) : Int = { + if (n == 0) ret(1) + else factC(n - 1, x => ret(n * x)) +} + +fact(10) +factC(10, identity) +\end{lstlisting} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] + + +\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm] +def fibC(n: Int, ret: Int => Int) : Int = { + if (n == 0 || n == 1) ret(1) else + fibC(n - 1, + r1 => fibC(n - 2, + r2 => ret(r1 + r2))) +} + +fibC(10, identity) +\end{lstlisting} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] - \Large\bf Are there more strings in \bl{$L(a^*)$} or + \Large\bf Are there more strings in \\ \hfill\bl{$L(a^*)$} or \bl{$L((a + b)^*)$}? \end{frame} @@ -71,6 +114,25 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] +\frametitle{Can you remember this HW?} + + \begin{itemize} + \item (1) How many basic regular expressions are there to match + the string \bl{$abcd$}? + \item (2) How many if they cannot include + \bl{$\ONE$} and \bl{$\ZERO$}? + \item (3) How many if they are also not + allowed to contain stars? + \item (4) How many if they are also + not allowed to contain \bl{$\_ + \_$}? + \end{itemize} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] \Large\bf There are more problems, than there are programs.\bigskip\bigskip\pause\\