# HG changeset patch # User Christian Urban # Date 1731133415 0 # Node ID ebb4a40d9bae3fa846d2c0f850ab2278b98307fe # Parent 51e00f223792c7529cabafcf61659dcc838c9756 updated diff -r 51e00f223792 -r ebb4a40d9bae progs/Matcher2.thy --- a/progs/Matcher2.thy Fri Oct 25 18:54:08 2024 +0100 +++ b/progs/Matcher2.thy Sat Nov 09 06:23:35 2024 +0000 @@ -131,7 +131,6 @@ by (auto) - section \Semantics of Regular Expressions\ fun diff -r 51e00f223792 -r ebb4a40d9bae progs/parser-combinators/comb1.sc --- a/progs/parser-combinators/comb1.sc Fri Oct 25 18:54:08 2024 +0100 +++ b/progs/parser-combinators/comb1.sc Sat Nov 09 06:23:35 2024 +0000 @@ -60,10 +60,19 @@ if (in != "" && in.head == c) Set((c, in.tail)) else Set() } + + val ap = CharParser('a') val bp = CharParser('b') +print(ap.parse("aade")) + val abp = SeqParser(ap, bp) +print(abp.parse("abade")) + +val abp = AltParser(ap, bp) +print(abp.parse("abc")) + MapParser(abp, ab => s"$ab").parse("abc") // an atomic parser for parsing strings according to a regex @@ -78,6 +87,8 @@ // atomic parsers for numbers and "verbatim" strings val NumParser = RegexParser("[0-9]+".r) +NumParser.parse("123abc345") + def StrParser(s: String) = RegexParser(Regex.quote(s).r) NumParser.parse("123a123bc") @@ -95,6 +106,8 @@ // // p"<_some_string_>" + + extension (sc: StringContext) def p(args: Any*) = StrParser(sc.s(args*)) @@ -124,7 +137,7 @@ val NumParserInt2 = NumParser.map(_.toInt) -val x = 1 + 3 + // A parser for palindromes (just returns them as string) // since the parser is recursive it needs to be lazy @@ -135,7 +148,7 @@ } // examples -Pal.parse_all("abacaba") +Pal.parse("abaaba") Pal.parse("abacaaba") println("Palindrome: " + Pal.parse_all("abaaaba")) @@ -157,6 +170,7 @@ // A parser for arithmetic expressions (Terms and Factors) + lazy val E: Parser[String, Int] = { (T ~ p"+" ~ E).map{ case ((x, _), z) => x + z } || (T ~ p"-" ~ E).map{ case ((x, _), z) => x - z } || T } @@ -178,8 +192,8 @@ // with parser combinators (and many other parsing algorithms) -// no left-recursion is allowed, otherwise the will loop; -// newer versions of Scala (3.5) will actually give a warning +// no left-recursion is allowed, otherwise they will loop; +// newer versions of Scala (3.5+) will actually give a warning // about this /* diff -r 51e00f223792 -r ebb4a40d9bae progs/parser-combinators/comb2-simple.sc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/parser-combinators/comb2-simple.sc Sat Nov 09 06:23:35 2024 +0000 @@ -0,0 +1,268 @@ +// Parser Combinators: +// Simple Version for WHILE-language +//==================================== +// +// +// call with +// +// amm comb2-simple.sc + + +trait IsSeq[I] { + extension (i: I) def isEmpty: Boolean +} + +given IsSeq[String] = _.isEmpty +given [I]: IsSeq[Seq[I]] = _.isEmpty + +// parser class +//============== + +abstract class Parser[I : IsSeq, T] { + def parse(in: I): Set[(T, I)] + + def parse_all(in: I) : Set[T] = + for ((hd, tl) <- parse(in); + if tl.isEmpty) yield hd +} + +// parser combinators +//==================== + +// alternative parser +class AltParser[I : IsSeq, T](p: => Parser[I, T], + q: => Parser[I, T]) extends Parser[I, T] { + def parse(in: I) = p.parse(in) ++ q.parse(in) +} + +// sequence parser +class SeqParser[I: IsSeq, T, S](p: => Parser[I, T], + q: => Parser[I, S]) extends Parser[I, (T, S)] { + def parse(in: I) = + for ((hd1, tl1) <- p.parse(in); + (hd2, tl2) <- q.parse(tl1)) yield ((hd1, hd2), tl2) +} + +// map parser +class MapParser[I : IsSeq, T, S](p: => Parser[I, T], + f: T => S) extends Parser[I, S] { + def parse(in: I) = for ((hd, tl) <- p.parse(in)) yield (f(hd), tl) +} + +// 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 map[S](f: => T => S) = new MapParser[I, T, S](p, f) +} + +// atomic parser for (particular) strings +case class StrParser(s: String) extends Parser[String, String] { + def parse(sb: String) = { + val (prefix, suffix) = sb.splitAt(s.length) + if (prefix == s) Set((prefix, suffix)) else Set() + } +} + +// atomic parser for identifiers (variable names) +case object IdParser extends Parser[String, String] { + val reg = "[a-z][a-z,0-9]*".r + def parse(sb: String) = reg.findPrefixOf(sb) match { + case None => Set() + case Some(s) => Set(sb.splitAt(s.length)) + } +} + +// atomic parser for numbers (transformed into Ints) +case object NumParser extends Parser[String, Int] { + val reg = "[0-9]+".r + def parse(sb: String) = reg.findPrefixOf(sb) match { + case None => Set() + case Some(s) => { + val (hd, tl) = sb.splitAt(s.length) + Set((hd.toInt, tl)) + } + } +} + +// the following string interpolation allows us to write +// StrParser(_some_string_) more conveniently as +// +// p"<_some_string_>" + +extension (sc: StringContext) + def p(args: Any*) = StrParser(sc.s(args*)) + +// the abstract syntax trees for the WHILE language +abstract class Stmt +abstract class AExp +abstract class BExp + +type Block = List[Stmt] + +case object Skip extends Stmt +case class If(a: BExp, bl1: Block, bl2: Block) extends Stmt +case class While(b: BExp, bl: Block) extends Stmt +case class Assign(s: String, a: AExp) extends Stmt +case class Write(s: String) extends Stmt + +case class Var(s: String) extends AExp +case class Num(i: Int) extends AExp +case class Aop(o: String, a1: AExp, a2: AExp) extends AExp + +case object True extends BExp +case object False extends BExp +case class Bop(o: String, a1: AExp, a2: AExp) extends BExp +case class And(b1: BExp, b2: BExp) extends BExp +case class Or(b1: BExp, b2: BExp) extends BExp + + +// 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 +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 +lazy val Fa: Parser[String, AExp] = + (p"(" ~ AExp ~ p")").map{ case ((_, y), _) => y } || + IdParser.map(Var(_)) || + NumParser.map(Num(_)) + +// boolean expressions with some simple nesting +lazy val BExp: Parser[String, BExp] = + (AExp ~ p"==" ~ AExp).map[BExp]{ case ((x, _), z) => Bop("==", x, z) } || + (AExp ~ p"!=" ~ AExp).map[BExp]{ case ((x, _), z) => Bop("!=", x, z) } || + (AExp ~ p"<" ~ AExp).map[BExp]{ case ((x, _), z) => Bop("<", x, z) } || + (AExp ~ p">" ~ AExp).map[BExp]{ case ((x, _), z) => Bop(">", x, z) } || + (p"(" ~ BExp ~ p")" ~ p"&&" ~ BExp).map[BExp]{ case ((((_, y), _), _), v) => And(y, v) } || + (p"(" ~ BExp ~ p")" ~ p"||" ~ BExp).map[BExp]{ case ((((_, y), _), _), v) => Or(y, v) } || + (p"true".map[BExp]{ _ => True }) || + (p"false".map[BExp]{ _ => False }) || + (p"(" ~ BExp ~ p")").map[BExp]{ case ((_, x), _) => x } + +// Stmt: a single statement +// Stmts: multiple statements +// Block: blocks (enclosed in curly braces) +lazy val Stmt: Parser[String, Stmt] = + ((p"skip".map[Stmt]{_ => Skip }) || + (IdParser ~ p":=" ~ AExp).map[Stmt]{ case ((x, _), z) => Assign(x, z) } || + (p"write(" ~ IdParser ~ p")").map[Stmt]{ case ((_, y), _) => Write(y) } || + (p"if" ~ BExp ~ p"then" ~ Block ~ p"else" ~ Block) + .map[Stmt]{ case (((((_, y), _), u), _), w) => If(y, u, w) } || + (p"while" ~ BExp ~ p"do" ~ Block).map[Stmt]{ case (((_, y), _), w) => While(y, w) }) +lazy val Stmts: Parser[String, Block] = + (Stmt ~ p";" ~ Stmts).map[Block]{ case ((x, _), z) => x :: z } || + (Stmt.map[Block]{ s => List(s) }) +lazy val Block: Parser[String, Block] = + ((p"{" ~ Stmts ~ p"}").map{ case ((_, y), _) => y } || + (Stmt.map(s => List(s)))) + + +// Examples +println(AExp.parse_all("2*2*2")) +println(BExp.parse_all("5+3")) +println(Stmt.parse_all("5==3")) +println(Stmt.parse_all("x2:=5+3")) +println(Block.parse_all("{x:=5;y:=8}")) +println(Block.parse_all("if(false)then{x:=5}else{x:=10}")) + +val fib = """n := 10; + minus1 := 0; + minus2 := 1; + temp := 0; + while (n > 0) do { + temp := minus2; + minus2 := minus1 + minus2; + minus1 := temp; + n := n - 1 + }; + result := minus2""".replaceAll("\\s+", "") + +println("fib testcase:") +println(Stmts.parse_all(fib)) + + +// an interpreter for the WHILE language +type Env = Map[String, Int] + +def eval_aexp(a: AExp, env: Env) : Int = + a match { + case Num(i) => i + case Var(s) => env(s) + case Aop("+", a1, a2) => eval_aexp(a1, env) + eval_aexp(a2, env) + case Aop("-", a1, a2) => eval_aexp(a1, env) - eval_aexp(a2, env) + case Aop("*", a1, a2) => eval_aexp(a1, env) * eval_aexp(a2, env) + case Aop("/", a1, a2) => eval_aexp(a1, env) / eval_aexp(a2, env) + } + +def eval_bexp(b: BExp, env: Env) : Boolean = + b match { + case True => true + case False => false + case Bop("==", a1, a2) => eval_aexp(a1, env) == eval_aexp(a2, env) + case Bop("!=", a1, a2) => !(eval_aexp(a1, env) == eval_aexp(a2, env)) + case Bop(">", a1, a2) => eval_aexp(a1, env) > eval_aexp(a2, env) + case Bop("<", a1, a2) => eval_aexp(a1, env) < eval_aexp(a2, env) + case And(b1, b2) => eval_bexp(b1, env) && eval_bexp(b2, env) + case Or(b1, b2) => eval_bexp(b1, env) || eval_bexp(b2, env) + } + +def eval_stmt(s: Stmt, env: Env) : Env = + s match { + case Skip => env + case Assign(x, a) => env + (x -> eval_aexp(a, env)) + case If(b, bl1, bl2) => if (eval_bexp(b, env)) eval_bl(bl1, env) else eval_bl(bl2, env) + case While(b, bl) => + if (eval_bexp(b, env)) eval_stmt(While(b, bl), eval_bl(bl, env)) + else env + case Write(x) => { println(env(x)) ; env } + } +def eval_bl(bl: Block, env: Env) : Env = + bl match { + case Nil => env + case s::bl => eval_bl(bl, eval_stmt(s, env)) + } + +def eval(bl: Block) : Env = eval_bl(bl, Map()) + +// parse + evaluate fib program; then lookup what is +// stored under the variable "result" +println(eval(Stmts.parse_all(fib).head)("result")) + + +// more examples + +// calculate and print all factors bigger +// than 1 and smaller than n +println("Factors") + +val factors = + """n := 12; + f := 2; + while (f < n / 2 + 1) do { + if ((n / f) * f == n) then { write(f) } else { skip }; + f := f + 1 + }""".replaceAll("\\s+", "") + +println(eval(Stmts.parse_all(factors).head)) + + +// calculate all prime numbers up to a number +println("Primes") + +val primes = + """end := 100; + n := 2; + while (n < end) do { + f := 2; + tmp := 0; + while ((f < n / 2 + 1) && (tmp == 0)) do { + if ((n / f) * f == n) then { tmp := 1 } else { skip }; + f := f + 1 + }; + if (tmp == 0) then { write(n) } else { skip }; + n := n + 1 + }""".replaceAll("\\s+", "") + +println(eval(Stmts.parse_all(primes).head)) diff -r 51e00f223792 -r ebb4a40d9bae progs/parser-combinators/comb2.sc --- a/progs/parser-combinators/comb2.sc Fri Oct 25 18:54:08 2024 +0100 +++ b/progs/parser-combinators/comb2.sc Sat Nov 09 06:23:35 2024 +0000 @@ -17,16 +17,24 @@ case class ~[+A, +B](x: A, y: B) +trait IsSeq[I] { + extension (i: I) def isEmpty: Boolean +} + +given IsSeq[String] = _.isEmpty +given [I]: IsSeq[Seq[I]] = _.isEmpty + + // parser combinators -abstract class Parser[I, T] { p => +abstract class Parser[I : IsSeq, T] { p => def parse(in: I): Set[(T, I)] - def parse_all(in: I)(using toSeq: I => Seq[?]) : Set[T] = + def parse_all(in: I) : Set[T] = for ((hd, tl) <- parse(in); - if toSeq(tl).isEmpty) yield hd + if tl.isEmpty) yield hd // alternative parser - def ||(q: => Parser[I, T]) = new Parser[I, T] { + def ||(q: => Parser[I, T]) : Parser[I, T] = Parser[I, T] { def parse(in: I) = p.parse(in) ++ q.parse(in) } diff -r 51e00f223792 -r ebb4a40d9bae slides/slides02.pdf Binary file slides/slides02.pdf has changed diff -r 51e00f223792 -r ebb4a40d9bae slides/slides02.tex --- a/slides/slides02.tex Fri Oct 25 18:54:08 2024 +0100 +++ b/slides/slides02.tex Sat Nov 09 06:23:35 2024 +0000 @@ -392,6 +392,56 @@ \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] + +\bl{$r ::= \ZERO \,\;|\;\, \ONE \,\;|\;\, c \,\;|\;\, r_1 + r_2 \,\;|\;\, r_1 \cdot r_2 \,\;|\;\, r^{*} \,\;|\;\, r^{\{n\}}$} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] + +\begin{center} +\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} +\bl{$nullable(\ZERO)$} & \bl{$\dn$} & \bl{\textit{false}}\\ +\bl{$nullable(\ONE)$} & \bl{$\dn$} & \bl{\textit{true}}\\ +\bl{$nullable (c)$} & \bl{$\dn$} & \bl{\textit{false}}\\ +\bl{$nullable (r_1 + r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \vee nullable(r_2)$} \\ +\bl{$nullable (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \wedge nullable(r_2)$} \\ +\bl{$nullable (r^*)$} & \bl{$\dn$} & \bl{\textit{true}}\\ +\bl{$nullable (r^{\{n\}})$} & \bl{$\dn$} & \bl{if $n = 0$ then \textit{true} else $nullable(r)$}\\ +\end{tabular} +\end{center} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] + +\begin{center} +\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} + \bl{$\der\, c\, (\ZERO)$} & \bl{$\dn$} & \bl{$\ZERO$} & \\ + \bl{$\der\, c\, (\ONE)$} & \bl{$\dn$} & \bl{$\ZERO$} & \\ + \bl{$\der\, c\, (d)$} & \bl{$\dn$} & \bl{if $c = d$ then $\ONE$ else $\ZERO$} & \\ + \bl{$\der\, c\, (r_1 + r_2)$} & \bl{$\dn$} & \bl{$\der\, c\, r_1 + \der\, c\, r_2$} & \\ + \bl{$\der\, c\, (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{if $nullable (r_1)$}\\ + & & \bl{then $(\der\,c\,r_1) \cdot r_2 + \der\, c\, r_2$}\\ + & & \bl{else $(\der\, c\, r_1) \cdot r_2$}\\ + \bl{$\der\, c\, (r^*)$} & \bl{$\dn$} & \bl{$(\der\,c\,r) \cdot (r^*)$}\\ + + \bl{$\der\, c\, (r^{\{n\}})$} & \bl{$\dn$} & \bl{if $n = 0$ then $\ZERO$ else $(\der\,c\,r) \cdot r^{\{n-1\}}$}\\ + + \end{tabular} +\end{center} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] diff -r 51e00f223792 -r ebb4a40d9bae slides/slides03.pdf Binary file slides/slides03.pdf has changed diff -r 51e00f223792 -r ebb4a40d9bae slides/slides03.tex --- a/slides/slides03.tex Fri Oct 25 18:54:08 2024 +0100 +++ b/slides/slides03.tex Sat Nov 09 06:23:35 2024 +0000 @@ -104,12 +104,12 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] -\frametitle{\boldmath$(abcdef)^{\{n\}}$ in Rust and Scala} +%%\frametitle{\boldmath$(abcdef)^{\{n\}}$ in Rust and Scala} \begin{textblock}{14}(1,3) \begin{tikzpicture} \begin{axis}[ - xlabel={copies of $[abcdef]$}, + xlabel={\bl{n} copies of \bl{\texttt{"}abcdef\texttt{"}}}, x label style={at={(0.45,-0.16)}}, ylabel={time in secs}, enlargelimits=false, @@ -122,7 +122,7 @@ width=10cm, height=6cm, legend entries={Rust, Scala V3}, - legend style={font=\small,at={(1.15,0.48)},anchor=north}, + legend style={font=\small,at={(1.0,0.48)},anchor=north}, legend cell align=left] \addplot[blue,mark=*, mark options={fill=white}] table {re-rust2.data}; \only<2>{\addplot[red,mark=*, mark options={fill=white}] table {re-scala2.data};} @@ -130,9 +130,63 @@ \end{tikzpicture} \end{textblock} +\begin{textblock}{9}(1.8,1.8) +{Regular expression: \bl{\texttt{(abcdef)$^{\{\textrm{n}\}}$}}} +\end{textblock} + +\begin{textblock}{6}(10.5,11.4) +{\bl{$n$}} +\end{textblock} + \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +%%\frametitle{\boldmath$(abcdef)^{\{n\}}$ in Rust and Scala} + +\begin{textblock}{14}(1,3) +\begin{tikzpicture} +\begin{axis}[ + xlabel={strings of the form \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}}, + x label style={at={(0.45,-0.16)}}, + ylabel={time in secs}, + enlargelimits=false, + xtick={0,5,10,...,30}, + xmax=35, + ymax=35, + ytick={0,10,...,30}, + scaled ticks=false, + axis lines=left, + width=10cm, + height=6cm, + legend entries={Python,JavaScript,Swift,Dart}, + legend style={font=\small,at={(1.15,0.78)},anchor=north}, + legend cell align=left] + \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; + \addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; + \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; + \addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data}; + +\end{axis} +\end{tikzpicture} +\end{textblock} + +\begin{textblock}{6}(1.8,1.8) +{Regular expression: \bl{\texttt{(a*)*$\,$b}}} +\end{textblock} + +\begin{textblock}{6}(10.5,11.4) +{\bl{$n$}} +\end{textblock} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% @@@@@@@@@@@@@@@@@ +\end{document} +% @@@@@@@@@@@@@@@@@@ + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] diff -r 51e00f223792 -r ebb4a40d9bae slides/slides06.pdf Binary file slides/slides06.pdf has changed diff -r 51e00f223792 -r ebb4a40d9bae slides/slides06.tex --- a/slides/slides06.tex Fri Oct 25 18:54:08 2024 +0100 +++ b/slides/slides06.tex Sat Nov 09 06:23:35 2024 +0000 @@ -22,7 +22,7 @@ \begin{document} - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[t] \frametitle{% @@ -36,7 +36,7 @@ \begin{center} \begin{tabular}{ll} Email: & christian.urban at kcl.ac.uk\\ - Office Hour: & Thurdays 15 -- 16\\ + Office Hour: & Fridays 12 -- 14\\ Location: & N7.07 (North Wing, Bush House)\\ Slides \& Progs: & KEATS\\ Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\ @@ -61,6 +61,30 @@ \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[t,fragile] +\begin{mybox3}{} + In CW2, be careful with the order of defining regular expressions: + +\begin{verbatim} +val COMMENT : Rexp = ... ~ EOL +val EOL : Rexp = "\r\n" | "\n" +\end{verbatim} +\end{mybox3} +\end{frame} + + +\begin{frame}[t,fragile] +\begin{mybox3}{} + In CW2, what is the derivative of RECD? + +\begin{center} +\bl{$der\;c\;RECD(l, r) \;\;\dn\;\; ???$} +\end{center} +\end{mybox3} +\end{frame} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c] @@ -436,13 +460,13 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[t,fragile] -\begin{mybox3}{} - In CW3, in the collatz program there is the line write "$\backslash$n" Should this print "/n" or perform the new line command /n ? Also should write be print() or println() ? -\end{mybox3} -\end{frame} - - +%\begin{frame}[t,fragile] +%\begin{mybox3}{} +% In CW3, in the collatz program there is the line write "$\backslash$n" Should this print "/n" or perform the new line command /n ? Also should write be print() or println() ? +%\end{mybox3} +%\end{frame} +% +% \begin{frame}<1-30>[c] \end{frame}