Binary file handouts/amm-ho.pdf has changed
--- a/handouts/amm-ho.tex Thu Sep 19 19:25:13 2024 +0100
+++ b/handouts/amm-ho.tex Sun Sep 29 18:46:02 2024 +0100
@@ -16,8 +16,7 @@
For the coursework in this module you are free to use any programming
language you like, but I will show you all my code using Scala---I
hope you have fond memories of Scala from PEP. The only difference
-with PEP is that I will use the current
-stable version of Scala, which at the time of writing is Scala 3.3.1.
+with PEP is that I will the Ammonite REPL for Scala 3.
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
If you intend to submit your code for the CW in Scala, you \underline{MUST} submit code that
@@ -51,8 +50,8 @@
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
$ amm
Loading...
-Welcome to the Ammonite Repl 2.5.9 (Scala 3.2.2 Java 17.0.7)
-scala> 1 + 2
+Welcome to the Ammonite Repl 3.0.0-M2 (Scala 3.3.3 Java 21.0.4)
+@ 1 + 2
res0: Int = 3
\end{lstlisting} %% $
@@ -68,7 +67,7 @@
\begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small]
$ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\
- download/2.5.9/3.2-2.5.9 --output amm
+ download/3.0.0-M2/3.3-3.0.0-M2 --output amm
\end{lstlisting} %% $
\noindent
@@ -78,7 +77,7 @@
\begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small]
$ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\
- download/2.5.9/3.2-2.5.9 --output amm.bat
+ download/3.0.0-M2/3.3-3.0.0-M2 --output amm.bat
\end{lstlisting} %% $
\noindent
Binary file handouts/ho01.pdf has changed
--- a/handouts/ho01.tex Thu Sep 19 19:25:13 2024 +0100
+++ b/handouts/ho01.tex Sun Sep 29 18:46:02 2024 +0100
@@ -51,7 +51,7 @@
compiler is an old craft going back to 1952 with the first compiler
written by Grace Hopper.\footnote{Who many years ago was invited on a
talk show hosted by David Letterman.
-\here{https://youtu.be/3N_ywhx6_K0?t=31}} Why studying compilers
+\here{https://youtu.be/oE2uls6iIEU}} Why studying compilers
nowadays? An interesting answer is given by John Regehr in his compiler
blog:\here{http://blog.regehr.org/archives/1419}
Binary file hws/hw01.pdf has changed
--- a/hws/hw01.tex Thu Sep 19 19:25:13 2024 +0100
+++ b/hws/hw01.tex Sun Sep 29 18:46:02 2024 +0100
@@ -18,16 +18,19 @@
\url{http://www.scala-lang.org}
\end{center}
- % and the Ammonite REPL from
- %
- % \begin{center}
- % \url{https://ammonite.io}
- % \end{center}
+ and the Ammonite REPL from
+
+ \begin{center}
+ \url{https://ammonite.io}
+ \end{center}
If you want to follow the code I present during the
lectures, it might be useful to install VS Code or Codium.
- I will be using Scala Version 3.5, which has the \texttt{scala-cli}
- REPL used in PEP already built in.
+ Please have a look at the handout about Ammonite and
+ if you need a refresher for Scala - I linked on KEATS
+ the Scala handout from PEP.
+ %I will be using Scala Version 3.5, which has the \texttt{scala-cli}
+ %REPL used in PEP already built in.
%handout about Scala.
%Make sure Ammonite
--- a/progs/catastrophic/catastrophic.py Thu Sep 19 19:25:13 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#!/usr/bin/env python3
-
-import re
-import sys
-
-# case of catastrophic backtracking in Python
-#
-# regex: (a*)*b
-# strings: aa...a
-#
-# call with timing as:
-#
-# time ./catastrophic.py 20
-
-# counter n given on the command line
-cn = sys.argv[1]
-
-# calling the matching function
-s = ("a" * int(cn))
-m = re.match('(a*)*b' , s)
-
-print(s)
-print(m)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/catastrophic/catastrophic.python Sun Sep 29 18:46:02 2024 +0100
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+
+# case of catastrophic backtracking in Python
+#
+# regex: (a*)*b
+# strings: aa...a
+#
+# call with timing as:
+#
+# time ./catastrophic.python 20
+
+# counter n given on the command line
+cn = sys.argv[1]
+
+# calling the matching function
+s = ("a" * int(cn))
+m = re.match('(a*)*b' , s)
+
+print(s)
+print(m)
--- a/progs/matcher/re1.sc Thu Sep 19 19:25:13 2024 +0100
+++ b/progs/matcher/re1.sc Sun Sep 29 18:46:02 2024 +0100
@@ -100,6 +100,7 @@
// test: (a?{n}) (a{n})
+@main
def test1() = {
println("Test (a?{n}) (a{n})")
@@ -109,6 +110,7 @@
}
// test: (a*)* b
+@main
def test2() = {
println("Test (a*)* b")
@@ -161,7 +163,7 @@
size(ders(("a" * 30).toList, BIG)) // 31010539
-
+@main
def test3() = {
println("Test (a + aa)*")
@@ -173,4 +175,6 @@
@main
def all() = { test1(); test2() ; test3() }
-//all()
+
+
+
--- a/progs/parser-combinators/comb2.sc Thu Sep 19 19:25:13 2024 +0100
+++ b/progs/parser-combinators/comb2.sc Sun Sep 29 18:46:02 2024 +0100
@@ -14,12 +14,12 @@
// case x ~ y ~ z => ...
-case class ~[+A, +B](x: A, y: B)
+case class o[+A, +B](x: A, y: B)
-type IsSeq[I] = I => Seq[_]
+type IsSeq[I] = I => Seq[?]
-abstract class Parser[I, T](using is: I => Seq[_]) {
+abstract class Parser[I, T](using is: I => Seq[?]) {
def parse(in: I): Set[(T, I)]
def parse_all(in: I) : Set[T] =
@@ -37,10 +37,10 @@
// sequence parser
class SeqParser[I : IsSeq, T, S](p: => Parser[I, T],
- q: => Parser[I, S]) extends Parser[I, ~[T, S]] {
+ q: => Parser[I, S]) extends Parser[I, o[T, S]] {
def parse(in: I) =
for ((hd1, tl1) <- p.parse(in);
- (hd2, tl2) <- q.parse(tl1)) yield (new ~(hd1, hd2), tl2)
+ (hd2, tl2) <- q.parse(tl1)) yield (new o(hd1, hd2), tl2)
}
// map parser
@@ -87,13 +87,13 @@
// p"<_some_string_>"
extension (sc: StringContext)
- def p(args: Any*) = StrParser(sc.s(args:_*))
+ def p(args: Any*) = StrParser(sc.s(args*))
// more convenient syntax for parser combinators
extension [I : IsSeq, T](p: Parser[I, T]) {
def ||(q : => Parser[I, T]) = new AltParser[I, T](p, q)
- def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
+ def o[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
def map[S](f: => T => S) = new MapParser[I, T, S](p, f)
}
@@ -124,13 +124,13 @@
// arithmetic expressions
lazy val AExp: Parser[String, AExp] =
- (Te ~ p"+" ~ AExp).map[AExp]{ case x ~ _ ~ z => Aop("+", x, z) } ||
- (Te ~ p"-" ~ AExp).map[AExp]{ case x ~ _ ~ z => Aop("-", x, z) } || Te
+ (Te o p"+" o AExp).map[AExp]{ case x o _ o z => Aop("+", x, z): AExp } ||
+ (Te o p"-" o AExp).map[AExp]{ case x o _ o z => Aop("-", x, z) } || Te
lazy val Te: Parser[String, AExp] =
- (Fa ~ p"*" ~ Te).map[AExp]{ case x ~ _ ~ z => Aop("*", x, z) } ||
- (Fa ~ p"/" ~ Te).map[AExp]{ case x ~ _ ~ z => Aop("/", x, z) } || Fa
+ (Fa o p"*" o Te).map[AExp]{ case x o _ o z => Aop("*", x, z) } ||
+ (Fa o p"/" o Te).map[AExp]{ case x o _ o z => Aop("/", x, z) } || Fa
lazy val Fa: Parser[String, AExp] =
- (p"(" ~ AExp ~ p")").map{ case _ ~ y ~ _ => y } ||
+ (p"(" o AExp o p")").map{ case _ o y o _ => y } ||
IdParser.map(Var(_)) ||
NumParser.map(Num(_))
--- a/progs/pow.scala Thu Sep 19 19:25:13 2024 +0100
+++ b/progs/pow.scala Sun Sep 29 18:46:02 2024 +0100
@@ -1,3 +1,4 @@
+
def concat(A: Set[String], B: Set[String]) : Set[String] =
for (x <- A ; y <- B) yield x ++ y
@@ -6,102 +7,11 @@
case n => concat(A, pow(A, n - 1))
}
-def powT(A: Set[String], n: Int, acc: Set[String] = Set("")) : Set[String] =
- n match {
- case 0 => acc
- case n => powT(A, n - 1, concat(acc, A))
- }
-
-
-val A = Set("a", "b", "c", "d", "e")
-val B = Set("a", "b", "c", "d", "")
-pow(A, 4).size
-pow(B, 4).size
-powT(A, 4).size
-powT(B, 4).size
-
-
-val C = Set("a", "b")
-
-pow(C, 100).size
-powT(C, 100000)
-
-val B = Set("aaa", "aaaa")
-concat(A, B).size // -> 3
-
-
-
-val A = Set("1", "2", "3", "")
-val B = Set("1", "2", "3", "4", "5", "6", "")
-concat(A, B).size // -> 28
-pow(B, 3).size
val A = Set("a", "b", "c", "d")
-pow(A, 4).size // -> 256
-
val B = Set("a", "b", "c", "")
-pow(B, 4)
-pow(B, 4).size // -> 121
-pow(B, 3).size
-
-
-val B2 = Set("a", "b", "c", "")
-pow(B2, 3).size // -> 40
-
-val C = Set("a", "b", "")
-pow(C, 2)
-pow(C, 2).size // -> 7
-
-pow(C, 3)
-pow(C, 3).size // -> 15
-
-
-//val A = Set("a", "b", "c", "d")
-//pow(A, 4).size
-
-//val A = Set("a", "b", "c")
-//pow(A, 5).size
-
-//val A = Set("a", "b", "")
-//pow(A, 5).size
-
-
-for (n <- (0 to 6).toList)
- yield pow(B, n).size
-
+pow(A, 4).size
+pow(B, 4).size
-
-
-val A = Set("a", "b", "c")
-pow(A, 3)
-pow(A, 3).size
-
-val B = Set("a", "b", "")
-pow(B, 4)
-pow(B, 4).size
-
-val C = Set("a", "")
-pow(C, 4)
-pow(C, 4).size
-
-val SA = Set("a", "b", "c", "d")
-val SB = Set("0", "1", "2", "3", "4", "5", "6")
-
-concat(SA, SB).size
-
-
-val SA2 = Set("ab", "a", "c", "d")
-val SB2 = Set("bc", "c", "2", "3", "4", "5", "6")
-
-concat(SA2, SB2).size
-
-
-/*
-((a b) c) d
-a (b (c d))
-(a b) (c d)
-(a (b c)) d
-a ((b c) d)
-*/
Binary file slides/slides01.pdf has changed
--- a/slides/slides01.tex Thu Sep 19 19:25:13 2024 +0100
+++ b/slides/slides01.tex Sun Sep 29 18:46:02 2024 +0100
@@ -6,7 +6,7 @@
\usepackage{../data}
\usetikzlibrary{cd}
\usepackage{listings-rust}
-
+\usepackage{ulem}
\usepackage{tcolorbox}
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
@@ -627,7 +627,7 @@
\footnotesize\textcolor{gray}{Grace Hopper}\smallskip\\
{\small\textcolor{gray}{(she made it to David Letterman's Tonight Show
- \here{https://www.youtube.com/watch?v=oE2uls6iIEU})}}
+ \here{https://youtu.be/oE2uls6iIEU})}}
\end{flushright}
\end{textblock}
@@ -635,25 +635,46 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+{\setbeamercolor{background canvas}{bg=cream}
\begin{frame}[c]
\frametitle{Some Housekeeping}
\textbf{Exam will be computer-based, invigilated in some big examination hall:}\bigskip
\begin{itemize}
-\item final exam in January (35\%)
-\item four CWs (65\% - first CW is optional)
+\item final exam in January (\xout{35\%} \textbf{40\%})
+\item coursework (\xout{65\%} \textbf{60\%- very first part is now optional})
\end{itemize}\bigskip\bigskip\pause
\textbf{Weekly Homework (optional):}
\begin{itemize}
\item uploaded on KEATS - solutions will be discussed during the SGTs
-\item \alert{\bf all} questions in the exam will be from the HWs!!
+\item \alert{\bf all} questions in the exam will be in some close shape or form from the HWs!!
\end{itemize}
+\end{frame}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+{
+\setbeamercolor{background canvas}{bg=cream}
+\begin{frame}[c]
+\frametitle{Homework}
+
+Until 3 years ago: I did not give out solutions; students
+sent emails to me and I responded to them individually.\bigskip\\
+
+Now: We will review the homework mainly during the SGTs.\bigskip\\\pause
+
+I will still choose the questions from the HW for the exam, but there might be
+some larger amount of deviation.\bigskip\pause
+
+Do not harass your TAs for the solutions!
+
\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\definecolor{rred}{HTML}{C0504D}
@@ -676,8 +697,8 @@
axis line style={-},
name=mygraph
]
-
-\addplot[ybar,style={rred,fill=rred!75,mark=none},text=black] coordinates {
+
+\only<1>{\addplot[ybar,style={rred,fill=rred!75,mark=none},text=black] coordinates {
(2024,136)
(2023,169)
(2022,111)
@@ -686,7 +707,17 @@
(2019,38)
(2018,20)
(2017,22)
-(2016,8)};
+(2016,8)}};
+\only<2>{\addplot[ybar,style={rred,fill=rred!75,mark=none},text=black] coordinates {
+(2024,173)
+(2023,169)
+(2022,111)
+(2021,98)
+(2020,59)
+(2019,38)
+(2018,20)
+(2017,22)
+(2016,8)}};
\end{axis}
\node[anchor=north, yshift=-10mm] at (mygraph.south) {\small{}Student numbers since the start of the compiler module.};
@@ -697,34 +728,16 @@
\end{frame}
}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
\setbeamercolor{background canvas}{bg=cream}
\begin{frame}[c]
-\frametitle{Homework}
-
-Until 2 years ago: I did not give out solutions; students
-sent emails to me and I responded to them individually.\bigskip\\
-
-
-Since last year: We will review the homework mainly during the SGTs.\bigskip\\\pause
-
-I will still choose the questions from the HW for the exam, but there might be
-some larger amount of deviation.
-
-\end{frame}
-}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
\frametitle{Some Housekeeping}
-\textbf{Coursework (5 accounting for 65\%):}\bigskip
+\textbf{Coursework (4 parts accounting for 60\%; submission deadline \underline{2nd January}):}\bigskip
\begin{itemize}
-\item matcher (5\%)
+\item matcher \xout{(5\%)}\;\;\textcolor{red}{optional from this year}
\item lexer (10\%)
\item parser / interpreter (10\%)
\item JVM compiler (15\%)
@@ -735,20 +748,61 @@
you can use any code I show you and is uploaded to KEATS\ldots\textbf{BUT NOTHING ELSE!}
\end{frame}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+{
+\setbeamercolor{background canvas}{bg=cream}
+\begin{frame}[c,fragile]
+\end{frame}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+{
+\setbeamercolor{background canvas}{bg=cream}
+\begin{frame}[c,fragile]
+%%\frametitle{Scala 3}
+I will show you all my code in Scala 3
+
+\begin{minipage}{1.4\textwidth}
+\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
+$ scala-cli
+Welcome to Scala 3.5.0 (21.0.4, Java OpenJDK 64-Bit Server VM).
+Type in expressions for evaluation. Or try :help.
+
+scala> 1 + 2
+res0: Int = 3
+\end{lstlisting} %% $
+\end{minipage}\medskip
+\pause
+
+Since Scala 3.5.0, scala-cli is included in "plain" Scala
+
+\begin{minipage}{1.4\textwidth}
+\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
+$ scala
+Welcome to Scala 3.5.1 (21.0.4, Java OpenJDK 64-Bit Server VM).
+Type in expressions for evaluation. Or try :help.
+
+scala>
+\end{lstlisting} %% $
+\end{minipage}
+\end{frame}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
\setbeamercolor{background canvas}{bg=cream}
\begin{frame}[c,fragile]
\frametitle{Ammonite \& Scala 3}
-I will show you all my code in Amm / Scala 3
+Actually in CFL, I will use Amm / Scala 3
\begin{minipage}{1.4\textwidth}
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
$ amm
Loading...
-Welcome to the Ammonite Repl 2.5.9 (Scala 3.2.2 Java 17.0.7)
+Welcome to the Ammonite Repl 3.0.0-M2 (Scala 3.3.3 Java 21.0.4)
scala> 1 + 2
res0: Int = 3
\end{lstlisting} %% $
@@ -777,7 +831,7 @@
\begin{itemize}
\item Harry Dilnot (harry.dilnot@kcl.ac.uk) \\
\;\;Windows expert
-\item Meilai Ji (meilai.ji@kcl.ac.uk)
+\item Oliver Iliffe (oliver.iliffe@kcl.ac.uk)
\end{itemize}
\end{frame}
@@ -1118,123 +1172,123 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-{
-\setbeamercolor{background canvas}{bg=cream}
-\begin{frame}[c]
-\frametitle{Rust vs.~Scala (from PEP)}
+% {
+% \setbeamercolor{background canvas}{bg=cream}
+% \begin{frame}[c]
+% \frametitle{Rust vs.~Scala (from PEP)}
-\mbox{}
+% \mbox{}
-\begin{minipage}{1.3\textwidth}
-\begin{mybox3}{}\it\small
-\textbf{Re: Another question of purely academic interest about regex implementation in cw3}
+% \begin{minipage}{1.3\textwidth}
+% \begin{mybox3}{}\it\small
+% \textbf{Re: Another question of purely academic interest about regex implementation in cw3}
-This conversation is interesting to me, and I've researched it a
-little bit [...] I also disagree with Dr.~Urban on the cost/benefit of
-non-GC languages [...]\smallskip
+% This conversation is interesting to me, and I've researched it a
+% little bit [...] I also disagree with Dr.~Urban on the cost/benefit of
+% non-GC languages [...]\smallskip
-But regardless, Scala is a lot slower than, say, C or Rust. To say
-it's not is basically wrong (imo). Perhaps one could argue that some
-of the guarantees Scala has makes it easier to write multi-threaded
-programs that utilise more of the CPU... but, in my opinion, this is
-also a bit misleading. Most CPUs have something like 4 to 12 cores
-nowadays. It's very possible that a given Scala program runs 4-12x
-slower than its Rust equivalent. Would you rather have your program
-run quickly and use a single core, or have it run equally
-quickly... and... hog your entire CPU for its duration?\ldots{}
+% But regardless, Scala is a lot slower than, say, C or Rust. To say
+% it's not is basically wrong (imo). Perhaps one could argue that some
+% of the guarantees Scala has makes it easier to write multi-threaded
+% programs that utilise more of the CPU... but, in my opinion, this is
+% also a bit misleading. Most CPUs have something like 4 to 12 cores
+% nowadays. It's very possible that a given Scala program runs 4-12x
+% slower than its Rust equivalent. Would you rather have your program
+% run quickly and use a single core, or have it run equally
+% quickly... and... hog your entire CPU for its duration?\ldots{}
-\mbox{}\hfill-- Oliver Iliffe, discussion from PEP
-\end{mybox3}
-\end{minipage}
+% \mbox{}\hfill-- Oliver Iliffe, discussion from PEP
+% \end{mybox3}
+% \end{minipage}
-\end{frame}
-}
+% \end{frame}
+% }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-{
-\setbeamercolor{background canvas}{bg=cream}
-\begin{frame}[c]
-\frametitle{Regex Lib in Rust}
+% {
+% \setbeamercolor{background canvas}{bg=cream}
+% \begin{frame}[c]
+% \frametitle{Regex Lib in Rust}
-\begin{center}
-\includegraphics[scale=0.34]{../pics/rust-regex.png}
-\end{center}
+% \begin{center}
+% \includegraphics[scale=0.34]{../pics/rust-regex.png}
+% \end{center}
-\end{frame}
-}
+% \end{frame}
+% }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-{
-\setbeamercolor{background canvas}{bg=cream}
-\begin{frame}[c,fragile]
+% {
+% \setbeamercolor{background canvas}{bg=cream}
+% \begin{frame}[c,fragile]
-\begin{columns}[t,onlytextwidth]
-\begin{column}{1\textwidth}
-\small re: \bl{$(abc)^{\{n\}}$}\quad str: \bl{$\underbrace{abc\ldots{}abc}_n$}\medskip\\
-\begin{tikzpicture}\footnotesize
-\begin{axis}[
- xlabel={$n$},
- x label style={at={(1.07,0.0)}},
- ylabel={time in secs},
- enlargelimits=false,
- xmax=65000,
- ymax=100,
- xtick={0,15000,...,60000},
- ytick={0,10,...,90},
- scaled ticks=false,
- axis lines=left,
- width=7cm,
- height=5cm]
- \addplot[black,mark=square*,mark options={fill=red}] table [x=x, y=y, col sep=comma, row sep=crcr]
- {x, y\\
- 0, 0\\
- 5000, 0.487\\
- 10000, 1.650\\
- 15000, 3.617\\
- 20000, 6.462\\
- 25000, 10.736\\
- 30000, 17.665\\
- 35000, 25.662\\
- 40000, 36.422\\
- 45000, 49.119\\
- 50000, 62.058\\
- 55000, 75.941\\
- 60000, 93.022\\
- };
-\end{axis}
-\end{tikzpicture}
-\end{column}
-\end{columns}
+% \begin{columns}[t,onlytextwidth]
+% \begin{column}{1\textwidth}
+% \small re: \bl{$(abc)^{\{n\}}$}\quad str: \bl{$\underbrace{abc\ldots{}abc}_n$}\medskip\\
+% \begin{tikzpicture}\footnotesize
+% \begin{axis}[
+% xlabel={$n$},
+% x label style={at={(1.07,0.0)}},
+% ylabel={time in secs},
+% enlargelimits=false,
+% xmax=65000,
+% ymax=100,
+% xtick={0,15000,...,60000},
+% ytick={0,10,...,90},
+% scaled ticks=false,
+% axis lines=left,
+% width=7cm,
+% height=5cm]
+% \addplot[black,mark=square*,mark options={fill=red}] table [x=x, y=y, col sep=comma, row sep=crcr]
+% {x, y\\
+% 0, 0\\
+% 5000, 0.487\\
+% 10000, 1.650\\
+% 15000, 3.617\\
+% 20000, 6.462\\
+% 25000, 10.736\\
+% 30000, 17.665\\
+% 35000, 25.662\\
+% 40000, 36.422\\
+% 45000, 49.119\\
+% 50000, 62.058\\
+% 55000, 75.941\\
+% 60000, 93.022\\
+% };
+% \end{axis}
+% \end{tikzpicture}
+% \end{column}
+% \end{columns}
-\begin{textblock}{10}(8.4,3.8)
-\tiny
-\begin{lstlisting}[language=Rust]
-extern crate regex;
+% \begin{textblock}{10}(8.4,3.8)
+% \tiny
+% \begin{lstlisting}[language=Rust]
+% extern crate regex;
-use regex::Regex;
-use std::time::Instant;
+% use regex::Regex;
+% use std::time::Instant;
-// bounded regular expression example
+% // bounded regular expression example
-fn main() {
- for bound in (0..=60000).step_by(5000) {
+% fn main() {
+% for bound in (0..=60000).step_by(5000) {
- let re = Regex::new(&format!("(abc){{{}}}", bound)).unwrap();
- let text = "abc".repeat(bound);
+% let re = Regex::new(&format!("(abc){{{}}}", bound)).unwrap();
+% let text = "abc".repeat(bound);
- let start_time = Instant::now();
- let is_match = re.is_match(&text);
- let elapsed_time = start_time.elapsed().as_secs_f64();
+% let start_time = Instant::now();
+% let is_match = re.is_match(&text);
+% let elapsed_time = start_time.elapsed().as_secs_f64();
- println!("Bound: {}, Match: {}, Time: {} seconds", bound, is_match, elapsed_time);
- }
-}
-\end{lstlisting}
-\end{textblock}
-\end{frame}
-}
+% println!("Bound: {}, Match: {}, Time: {} seconds", bound, is_match, elapsed_time);
+% }
+% }
+% \end{lstlisting}
+% \end{textblock}
+% \end{frame}
+% }
@@ -1982,11 +2036,13 @@
\begin{tabular}{lll}
- SGT TAs: & Flavio Melinte Citea & (was a KURF last summer)\\
- & Krishi Wali \\
- & Meilai Ji \medskip\\
+ SGT TAs: & Flavio Melinte Citea & (was a KURF two summers ago)\\
+ & Zishan Rahman\\
+ & Harry Dilnot\\
+ & Opale Sjostedt\medskip\\
Amm Helpers & Harry Dilnot & (harry.dilnot@kcl.ac.uk)\\
- & Meilai Ji & (meilai.ji@kcl.ac.uk)\medskip\\
+ & Oliver Iliffe & (oliver.iliffe@kcl.ac.uk)\medskip\\
+ & \multicolumn{2}{l}{\hspace{5mm}(was a KURF last summer)}\\
\end{tabular}
\mbox{}
\end{frame}
--- a/solutions/cw4/parser.sc Thu Sep 19 19:25:13 2024 +0100
+++ b/solutions/cw4/parser.sc Sun Sep 29 18:46:02 2024 +0100
@@ -1,7 +1,6 @@
// CW3
import scala.language.implicitConversions
-
import $file.lexer, lexer._
case class ~[+A, +B](x: A, y: B)