Binary file handouts/ho03.pdf has changed
--- a/handouts/ho03.tex Thu Oct 24 14:39:29 2019 +0100
+++ b/handouts/ho03.tex Fri Oct 25 14:55:31 2019 +0100
@@ -999,7 +999,7 @@
the corresponding subset as \emph{the} starting state of the DFA.
The accepting states in the DFA are given by all sets that contain a
-$2$, which is the only accpting state in this NFA. But again in
+$2$, which is the only accepting state in this NFA. But again in
general if the subset contains any accepting state from the NFA, then
the corresponding state in the DFA is accepting as well. This
completes the subset construction. The corresponding DFA for the NFA
@@ -1057,7 +1057,7 @@
up in the number of states in the DFA is again bad news for how
quickly you can decide whether a string is accepted by a DFA or
not. So the caveat with DFAs is that they might make the task of
-finding the next state trival, but might require $2^n$ times as many
+finding the next state trivial, but might require $2^n$ times as many
states then a NFA.\bigskip
\noindent
@@ -1085,7 +1085,7 @@
needs to produce the next state: this is the set of all NFA states
that are reachable from each state in \texttt{qs}. The function
\texttt{nexts} from the NFA class already calculates this for us. The
-accepting-states function for the DFA is true henevner at least one
+accepting-states function for the DFA is true whenever at least one
state in the subset is accepting (that is true) in the NFA.\medskip
\noindent
@@ -1256,7 +1256,7 @@
By the way, we are not bothering with implementing the above
-minimisation algorith: while up to now all the transformations used
+minimisation algorithm: while up to now all the transformations used
some clever composition of functions, the minimisation algorithm
cannot be implemented by just composing some functions. For this we
would require a more concrete representation of the transition
--- a/progs/comb1.scala Thu Oct 24 14:39:29 2019 +0100
+++ b/progs/comb1.scala Fri Oct 25 14:55:31 2019 +0100
@@ -5,7 +5,7 @@
* constraint IsSeq, which means that the input type 'I' needs
* to be a sequence. */
- type IsSeq[A] = A => Seq[_]
+type IsSeq[A] = A => Seq[_]
abstract class Parser[I : IsSeq, T] {
def parse(ts: I): Set[(T, I)]
@@ -84,6 +84,7 @@
("b" ~ Pal ~ "b") ==> { case ((x, y), z) => x + y + z } || "a" || "b" || "")
Pal.parse_all("abaaaba")
+Pal.parse_all("abacba")
Pal.parse("abaaaba")
println("Palindrome: " + Pal.parse_all("abaaaba"))
@@ -97,6 +98,13 @@
P.parse_all(")(")
P.parse_all("()")
+lazy val PC : Parser[String, Int] =
+ ("(" ~ PC ~ ")" ~ PC ==> { case (((_, x), _), y) => x + y + 2 } ||
+ "" ==> { (s) => 0 })
+
+PC.parse_all("(((()()))())")
+P.parse_all("(((()()))()))")
+
// Arithmetic Expressions (Terms and Factors)
lazy val E: Parser[String, Int] =
Binary file slides/slides05.pdf has changed
--- a/slides/slides05.tex Thu Oct 24 14:39:29 2019 +0100
+++ b/slides/slides05.tex Fri Oct 25 14:55:31 2019 +0100
@@ -40,7 +40,25 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+ \frametitle{Coursework 1: Submissions}
+
+ \begin{itemize}
+ \item Scala (29)
+ \item Haskell (1)
+ \item Kotlin (1)
+ \item Rust (1)
+ \end{itemize}\bigskip\bigskip
+
+ \small
+ Please get in contact if you intend to do CW Strand 2. No zips please.
+ Give definitions also on paper if asked. BTW, simp
+ can stay unchanged. Use \texttt{ders} for CW2, not \texttt{ders2}!
+ \end{frame}
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{\begin{tabular}{c}Last Week\\[-2mm]
@@ -356,24 +374,6 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Coursework 1: Submissions}
-
-\begin{itemize}
-\item Scala (29)
-\item Haskell (1)
-\item Kotlin (1)
-\item Rust (1)
-\end{itemize}\bigskip\bigskip
-
-\small
-Please get in contact if you intend to do CW Strand 2. No zips please.
-Give definitions also on paper, if asked, and be truthful! BTW, simp
-can stay unchanged. Use \texttt{ders} for CW2, not \texttt{ders2}!
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%