updated
authorChristian Urban <urbanc@in.tum.de>
Wed, 30 Oct 2019 14:07:58 +0000
changeset 288 65731df141a5
parent 287 c493eaba6018
child 289 08b5ddbc7e55
updated
cws/cw01.pdf
cws/cw05.pdf
marking4/bf.scala
marking4/bf1a_test.scala
marking4/bf1b_test.scala
marking4/bf1c_test.scala
marking4/bf_test.sh
marking4/compare
marking4/output
marking4/postfix.scala
marking4/postfix2.scala
marking4/postfix_test.sh
marking4/postfix_test7.scala
marking4/postfix_test8.scala
marking4/postfix_test9.scala
marking4/re.scala
marking4/re_test.sh
marking4/re_test1.scala
marking4/re_test2.scala
marking4/re_test3.scala
marking4/re_test4.scala
marking4/re_test5.scala
marking4/re_test6.scala
marking4/tails
templates4/postfix.scala
templates4/postfix2.scala
templates4/re.scala
testing4/bf.scala
testing4/bf1a_test.scala
testing4/bf1b_test.scala
testing4/bf1c_test.scala
testing4/bf_test.sh
Binary file cws/cw01.pdf has changed
Binary file cws/cw05.pdf has changed
--- a/marking4/bf.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,462 +0,0 @@
-// Part 2 about an Interpreter for the Brainf*** language
-//========================================================
-
-object CW8b {
-
-type Mem = Map[Int, Int]
-
-// (2a) Complete the functions for safely reading  
-// and writing brainf*** memory. Safely read should
-// Return the value stored in the Map for a given memory
-// pointer, if it exists; otherwise it Returns 0. The
-// writing function generates a new Map with the
-// same data, except at the given memory pointer the
-// value v is stored.
-
-
-def sread(mem: Mem, mp: Int) : Int = 
-  mem.getOrElse(mp, 0)
-
-def write(mem: Mem, mp: Int, v: Int) : Mem =
-  mem.updated(mp, v)
-
-
-// (2b) Implement the two jumping instructions in the 
-// brainf*** language. In jumpRight, given a program and 
-// a program counter move the program counter to the right 
-// until after the *matching* ]-command. Similarly, 
-// jumpLeft implements the move to the left to just after
-// the *matching* [--command.
-
-def jumpRight(prog: String, pc: Int, level: Int) : Int = {
-  if (prog.length <= pc) pc 
-  else (prog(pc), level) match {
-    case (']', 0) => pc + 1
-    case (']', l) => jumpRight(prog, pc + 1, l - 1)
-    case ('[', l) => jumpRight(prog, pc + 1, l + 1)
-    case (_, l) => jumpRight(prog, pc + 1, l)
-  }
-}
-
-def jumpLeft(prog: String, p: Int, level: Int) : Int = {
-  if (p < 0) p 
-  else (prog(p), level) match {
-    case ('[', 0) => p + 1
-    case ('[', l) => jumpLeft(prog, p - 1, l - 1)
-    case (']', l) => jumpLeft(prog, p - 1, l + 1)
-    case (_, l) => jumpLeft(prog, p - 1, l)
-  }
-}
-
-//jumpLeft("[******]***", 7, 0)
-
-// (2c) Complete the run function that interpretes (runs) a brainf***
-// program: the arguments are a program, a program counter,
-// a memory counter and a brainf*** memory. It Returns the
-// memory at the stage when the excution of the brainf*** program
-// finishes. The interpretation finishes once the program counter
-// pc is pointing to something outside the program string.
-// If the pc points to a character inside the program, the pc, 
-// memory pointer and memory need to be updated according to 
-// rules of the brainf*** language. Then, recursively, run 
-// function continues with the command at the new program
-// counter. 
-// Implement the start function that calls run with the program
-// counter and memory counter set to 0.
-
-def run(prog: String, pc: Int, mp: Int, mem: Mem) : Mem = {
-  if (0 <= pc && pc < prog.length) { 
-    val (new_pc, new_mp, new_mem) = prog(pc) match {
-      case '>' => (pc + 1, mp + 1, mem)
-      case '<' => (pc + 1, mp - 1, mem)
-      case '+' => (pc + 1, mp, write(mem, mp, sread(mem, mp) + 1))
-      case '-' => (pc + 1, mp, write(mem, mp, sread(mem, mp) - 1))
-      case '.' => { print(sread(mem, mp).toChar); (pc + 1, mp, mem) }
-      case ',' => (pc + 1, mp, write(mem, mp, Console.in.read().toByte))
-      case '['  => 
-	if (sread(mem, mp) == 0) (jumpRight(prog, pc + 1, 0), mp, mem) else (pc + 1, mp, mem) 
-      case ']'  => 
-	if (sread(mem, mp) != 0) (jumpLeft(prog, pc - 1, 0), mp, mem) else (pc + 1, mp, mem) 
-      case _ => (pc + 1, mp, mem)
-    }		     
-    run(prog, new_pc, new_mp, new_mem)	
-  }
-  else mem
-}
-
-def start(prog: String, m: Mem) = run(prog, 0, 0, m)
-
-// some sample programs collected from the Internet
-//==================================================
-
-
-/*
-// first some contrived (small) programs
-
-// clears the 0-cell
-start("[-]", Map(0 -> 100)) 
-
-// copies content of the 0-cell to 1-cell
-start("[->+<]", Map(0 -> 10))
-
-// copies content of the 0-cell to 2-cell and 4-cell
-start("[>>+>>+<<<<-]", Map(0 -> 42))
-
-
-// prints out numbers 0 to 9
-start("""+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]""", Map())
-
-
-// some more "useful" programs
-
-// hello world program 1
-start("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
-       ..+++.>>.<-.<.+++.------.--------.>>+.>++.""", Map())
-
-// hello world program 2
-start("""++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>+
-      +.<<+++++++++++++++.>.+++.------.--------.>+.>.""", Map())
-
-
-// draws the Sierpinski triangle
-start("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
-      ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
-      ]>.>+[>>]>+]""", Map())
-
-println(start("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
-      ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
-      ]>.>+[>>]>+]""", Map())) 
-
-//fibonacci numbers below 100
-start("""+++++++++++
-      >+>>>>++++++++++++++++++++++++++++++++++++++++++++
-      >++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
-      +<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
-      <-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
-      -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
-      >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
-      +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
-      ++++++++++++++++++++++++++++++++++++++++++++.[-]<<
-      <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
-      [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]""", Map())
-
-
-//outputs the square numbers up to 10000
-start("""++++[>+++++<-]>[<+++++>-]+<+[
-    >[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+
-    >>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]
-    <<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]""", Map())
-
-//collatz numbers (need to be typed in)
-start(""">,[[----------[
-      >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<]
-      ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],<]>]>>>++>+>>[
-      <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>]
-      >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]]
-      >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>>
-      ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<,]""", Map())
-
-
-// infinite collatz (never stops)
-start(""">>+>+<[[->>[>>]>>>[>>]+[<<]<<<[<<]>[>[>>]>>+>[>>]<+<[<<]<<<[<
-      <]>-]>[>>]>>[<<<<[<<]>+>[>>]>>-]<<<<[<<]+>>]<<[+++++[>+++++++
-      +<-]>.<++++++[>--------<-]+<<]>>[>>]+[>>>>[<<+>+>-]<-[>+<-]+<
-      [<<->>-[<<+>>[-]]]>>>[<<<+<<+>>>>>-]<<<[>>>+<<<-]<<[[-]>+>>->
-      [<+<[<<+>>-]<[>+<-]<[>+<-]>>>>-]<[>+<-]+<[->[>>]<<[->[<+++>-[
-      <+++>-[<+++>-[<[-]++>>[-]+>+<<-[<+++>-[<+++>-[<[-]+>>>+<<-[<+
-      ++>-[<+++>-]]]]]]]]]<[>+<-]+<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<
-      +>-[<+>-[<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-[<+>-]]]]]]]]]]]<[>+<-
-      ]+>>]<<[<<]>]<[->>[->+>]<[-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<-
-      >>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>
-      -[<->>+<-[<+>-[<->>+<-[<+>-]]]]]]]]]]]]]]]]]]]>[<+>-]<+<[<+++
-      +++++++>-]<]>>[<+>->>]<<[>+>+<<-]>[<+>-]+>[<->[-]]<[-<<-]<<[<
-      <]]++++++[>+++++++<-]>++.------------.[-]>[>>]<<[+++++[>+++++
-      +++<-]>.<++++++[>--------<-]+<<]+<]>[<+>-]<]>>>[>>]<<[>[-]<-<
-      <]++++++++++.[-]<<<[<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<+>-[<+>-
-      [<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-]]]]]]]]]]<[>+<-]+>>]<<[<<]>>]""", Map())
-
-
-start("""+++++[>+++++++++<-],[[>--.++>+<<-]>+.->[<.>-]<<,]""", Map())
-
-*/ 
-
-/*
-def splice(cs: List[Char], acc: List[(Char, Int)]) : List[(Char, Int)] = (cs, acc) match {
-  case (Nil, acc) => acc
-  case (c :: cs, Nil) => splice(cs, List((c, 1)))
-  case (c :: cs, (d, n) :: acc) => 
-    if (c == d) splice(cs, (c, n + 1) :: acc)
-    else splice(cs, (c, 1) :: (d, n) :: acc)
-}
-
-def spl(s: String) = splice(s.toList, Nil).reverse
-
-
-// simple instructions
-def instr(c: Char) : String = c match {
-  case '>' => "ptr++;"
-  case '<' => "ptr--;"
-  case '+' => "(*ptr)++;"
-  case '-' => "(*ptr)--;"
-  case '.' => "putchar(*ptr);"
-  case ',' => "*ptr = getchar();\n"
-  case '['  => "while(*ptr){"
-  case ']'  => "}"
-  case _ => ""
-}
-
-def instrs(prog: String) : String =
-  prog.toList.map(instr(_)).mkString
-
-
-//optimised instructions
-
-def instr2(c: Char, n: Int) : String = c match {
-  case '>' => "ptr += " + n.toString + ";"
-  case '<' => "ptr -= " + n.toString + ";"
-  case '+' => "(*ptr) += " + n.toString + ";"
-  case '-' => "(*ptr) -= " + n.toString + ";"
-  case '.' => "putchar(*ptr);" * n
-  case ',' => "*ptr = getchar();\n" * n
-  case '['  => "while(*ptr){" * n
-  case ']'  => "}" * n
-  case _ => ""
-}
-
-def instrs2(prog: String) : String =
-  spl(prog).map{ case (c, n) => instr2(c, n) }.mkString
-
-
-// peephole optimisers are at
-// https://github.com/Wilfred/bfc#peephole-optimisations
-// http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck.html
-
-def compile_str(prog: String) : String = {
-  "#include <string.h>\n" ++
-  "#include <stdio.h>\n" ++
-  "char field[30000];\n" ++
-  "char *ptr = &field[15000];" ++
-  "int main()\n{\n" ++
-  "memset(field, '\\0', 30000);\n" ++
-  instrs2(prog) ++
-  "\n re turn 0;\n}"
-}
-
-def compile(name: String, prog: String) = {
-  val fw = new java.io.FileWriter(name + ".c") 
-  fw.write(compile_str(prog)) 
-  fw.close()
-}
-
-import sys.process._
-
-def compile_run(prog: String) = {
-  compile("tmp", prog)
-  "gcc -O3 -o tmp tmp.c".!
-  "./tmp".!
-  ()
-}
-
-
-compile_run("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
-       ..+++.>>.<-.<.+++.------.--------.>>+.>++.""")
-
-compile_run("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
-      ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
-      ]>.>+[>>]>+]""")
-
-compile_run("""      A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
-+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
->>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
-<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
->+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>
->>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>
->>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>
->>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>
-[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<
-<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[
->>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[
->+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[
--<<+>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<<<<[<<<<<<<<<]]>>>>>>>>>[>>>>>>>>>]<<<<<<<
-<<[>[->>>>>>>>>+<<<<<<<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<<<[<<<<<<<<<]>>>>[-]<<<++++
-+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
-<<<<<]]>>>]""")
-
-compile_run("""
->+>+>+>+>++<[>[<+++>-
-
-  >>>>>
-  >+>+>+>+>++<[>[<+++>-
-
-    >>>>>
-    >+>+>+>+>++<[>[<+++>-
-
-      >>>>>
-      >+>+>+>+>++<[>[<+++>-
-
-        >>>>>
-        +++[->+++++<]>[-]<
-        <<<<<
-
-      ]<<]>[-]
-      <<<<<
-
-    ]<<]>[-]
-    <<<<<
-
-  ]<<]>[-]
-  <<<<<
-
-]<<]>.""")
-
-// benchmarks
-compile_run(""">++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++
-[>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++
-++++++++[>++++++++++[>++++++++++[>++++++++++[>+
-+++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.""")
-
-//
-compile_run("""++++[>++++<-]>[>+>++>[+++++++>]+++[<]>-]>>>>>>>>-.
-<<<<.<..+++.<.>>>>.<<<.+++.------.>-.<<+.<------.""")
-
-compile_run("""++++++++[->-[->-[->-[-]<]<]<]
->++++++++[<++++++++++>-]<[>+>+<<-]>-.>-----.>""")
-
-
-
-
-// register to BF compiler
-// https://gergo.erdi.hu/blog/2010-09-06-from_register_machines_to_brainfuck,_part_1/
-
-*/
-
-}
--- a/marking4/bf1a_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-//import scala.language.reflectiveCalls
-
-//lazy val f = Future {
-  import CW8b._
-
-  assert(sread(Map(), 2) == 0)
-  assert(sread(Map(2 -> 1), 2) == 1)
-  assert(write(Map(), 1, 2) == Map(1 -> 2))
-  assert(write(Map(1 -> 0), 1, 2) == Map(1 -> 2))
-//}
-
-//Await.result(f, 120 second)
--- a/marking4/bf1b_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-//import scala.language.reflectiveCalls
-
-//lazy val f = Future {
-  import CW8b._
-
-  assert(jumpRight("[******]***", 1, 0) == 8)
-  assert(jumpRight("[**[*]*]***", 1, 0) == 8)
-  assert(jumpRight("[**[*]*]***", 1, 0) == 8)  
-  assert(jumpRight("[**[***]***", 1, 0) == 11)
-  assert(jumpRight("[*[][]*]***", 1, 0) == 8)
-  assert(jumpLeft("[******]***", 6, 0) == 1)
-  assert(jumpLeft("[******]***", 7, 0) == -1)
-  assert(jumpLeft("[*[][]*]***", 6, 0) == 1)
-//}
-
-//Await.result(f, 120 second)
--- a/marking4/bf1c_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-import CW8b._
-
-assert(start("[-]", Map(0 -> 100)) == Map(0 -> 0))
-assert(start("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
-assert(start("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
-
-val hello = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
-               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
-assert(start(hello, Map()) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
-
-assert(start("+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]", Map()) == Map(0 -> 0, 1 -> 58, 2 -> 32))
-
-val hello2 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.!!!!!!!!!"""
-
-assert(start(hello2, Map()) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
-
--- a/marking4/bf_test.sh	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-#!/bin/bash
-
-# to make the script fail safely
-set -euo pipefail
-
-
-out=${1:-output}
-
-echo "" > $out
-
-
-echo "Below is the feedback and provisional marks for your submission" >> $out
-echo "for assignment 8 Part 2.  Please note all marks are provisional until" >> $out
-echo "ratified by the assessment board -- this is not an official" >> $out
-echo "results transcript." >> $out
-echo "" >> $out
-
-# marks for CW8 part 2
-marks=$(( 0 ))
-
-# compilation tests
-
-function scala_compile {
-    (ulimit -t 360; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
-}
-
-# functional tests
-
-function scala_assert {
-    (ulimit -t 360; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
-}
-
-
-# purity test
-
-function scala_vars {
-   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
-}
-
-
-
-# var, return, ListBuffer test
-#
-echo "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
-
-if (scala_vars bf.scala)
-then
-  echo "  --> test failed" | tee -a $out
-  tsts0=$(( 1 ))
-else
-  echo "  --> success" | tee -a $out
-  tsts0=$(( 0 )) 
-fi
-
-
-# compilation test
-if  [ $tsts0 -eq 0 ]
-then    
-  echo "bf.scala runs?" | tee -a $out
-
-  if (scala_compile bf.scala)
-  then
-    echo "  --> success" | tee -a $out
-    tsts1=$(( 0 ))
-  else
-    echo "  --> scala bf.scala did not run successfully" | tee -a $out
-    tsts1=$(( 1 )) 
-  fi
-else
-  tsts1=$(( 1 ))     
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-  echo " sread(Map(), 2) == 0" | tee -a $out
-  echo " sread(Map(2 -> 1), 2) == 1" | tee -a $out  
-  echo " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
-  echo " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
-  
-  if (scala_assert "bf.scala" "bf1a_test.scala")
-  then
-      echo "  --> success" | tee -a $out
-      marks=$(( marks + 1 ))
-  else
-    echo "  --> test failed" | tee -a $out
-  fi
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-    echo " jumpRight(\"[******]***\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[**[*]*]***\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[**[*]*]***\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[**[***]***\", 1, 0) == 11" | tee -a $out
-    echo " jumpRight(\"[*[][]*]***\", 1, 0) == 8" | tee -a $out
-    echo " jumpLeft(\"[******]***\", 6, 0) == 1" | tee -a $out
-    echo " jumpLeft(\"[******]***\", 7, 0) == -1" | tee -a $out
-    echo " jumpLeft(\"[*[][]*]***\", 6, 0) == 1" | tee -a $out
-  
-  if (scala_assert "bf.scala" "bf1b_test.scala")
-  then
-      echo "  --> success" | tee -a $out
-      marks=$(( marks + 1 ))
-  else
-      echo "  --> test failed" | tee -a $out
-  fi
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-  echo " start(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
-  echo " start(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
-  echo " start(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
-  echo " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
-  echo "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
-  echo " start(hello, Map()) == " | tee -a $out
-  echo "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
-  echo " start(\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\", Map()) == " | tee -a $out
-  echo "       Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
-  
-  if (scala_assert "bf.scala" "bf1c_test.scala")
-  then
-      echo "  --> success" | tee -a $out
-      marks=$(( marks + 2 ))
-  else
-      echo "  --> test failed" | tee -a $out
-  fi
-fi
-
-
-## final marks
-echo "Overall mark for CW 8, Part 2" | tee -a $out
-echo "$marks" | tee -a $out
-
--- a/marking4/compare	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#!/bin/sh
-###set -e
-
-trap "exit" INT
-
-files=${1:-assignment20189-*}
-
-for sd in $files; do
-  cd $sd
-  cp output output1
-  #cmp -s output output1 > /dev/null
-  #if [ $? -eq 1 ]; then
-  #    echo $sd + "is different"
-  #fi
-  cd ..
-done
-
-
--- a/marking4/output	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/output	Wed Oct 30 14:07:58 2019 +0000
@@ -1,46 +1,95 @@
 
 Below is the feedback and provisional marks for your submission
-for assignment 9 Part 2.  Please note all marks are provisional until
+for the core part of assignment 9.  Please note all marks are provisional until
 ratified by the assessment board -- this is not an official
 results transcript.
 
-postfix.scala does not contain vars, returns, Arrays, ListBuffers etc?
+re.scala does not contain vars, returns, Arrays, ListBuffers etc?
   --> success
-postfix.scala runs?
+re.scala runs?
   --> success
- syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "\*", "+")
- syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+")
- syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+")
- syard(split("5 * 7 / 2")) == List("5", "7", "\*", "2", "/")
+ nullable(ZERO) == false
+ nullable(ONE) == true
+ nullable(CHAR('a')) == false
+ nullable(ZERO | ONE) == true
+ nullable(ZERO | CHAR('a')) == false
+ nullable(ONE ~  ONE) == true
+ nullable(ONE ~ CHAR('a')) == false
+ nullable(STAR(ZERO)) == true
   --> success
- compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7
- compute(syard(split("10 + 12 * 33"))) == 406
- compute(syard(split("( 5 + 7 ) * 2"))) == 24
- compute(syard(split("5 + 7 / 2"))) == 8
- compute(syard(split("5 * 7 / 2"))) == 17
- compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15
-  --> success
-postfix2.scala does not contain vars, returns, Arrays, ListBuffers etc?
-  --> success
-postfix2.scala runs?
+ der('a', ZERO | ONE) == (ZERO | ZERO)
+ der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)
+ der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')
+ der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))
+ der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))
+
+ val r0 = "a" ~ "b" ~ "c"
+ assert(der('a', r0) == (ONE ~ "b") ~ "c")
+ assert(der('b', r0) == (ZERO ~ "b") ~ "c")
+ assert(der('c', r0) == (ZERO ~ "b") ~ "c")
+
+ val r1 = (ONE ~ "b") ~ "c"
+ assert(der('a', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
+ assert(der('b', r1) == ((ZERO ~ "b") | ONE) ~ "c")
+ assert(der('c', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
+
+ val r2 = ((ZERO ~ "b") | ONE) ~ "c"
+ assert(der('a', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
+ assert(der('b', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
+ assert(der('c', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))
   --> success
- syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "\*", "+")
- syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+")
- syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+")
- syard(split("5 * 7 / 2")) == List("5", "7", "\*", "2", "/")
- syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == 
-         List("3", "4", "8", "\*", "5", "1", "-", "2", "3", "^", "^", "/", "+")
- 
- compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7
- compute(syard(split("10 + 12 * 33"))) == 406
- compute(syard(split("( 5 + 7 ) * 2"))) == 24
- compute(syard(split("5 + 7 / 2"))) == 8
- compute(syard(split("5 * 7 / 2"))) == 17
- compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15
- compute(syard(split("4 ^ 3 ^ 2"))) == 262144
- compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144
- compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096
- compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536
+ simp(ZERO | ONE) == ONE
+ simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)
+ simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')
+ simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
+ simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
+ simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO
+ simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')
+ simp(CHAR('a') | CHAR('a')) == CHAR('a')
+ simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')
+ simp(ONE | CHAR('a')) == (ONE | CHAR('a'))
+ simp(ALT((CHAR('a') | ZERO) ~ ONE,
+          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')
+ simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO
+ simp(ALT(ONE | ONE, ONE | ONE)) == ONE
+ simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')
   --> success
-Overall mark for CW 9, Part 2
-4
+ val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
+ ders(("a" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))
+ ders(List('b'),EVIL) == ONE
+ ders(List('b','b'),EVIL) == ZERO
+ matcher(EVIL, "a" * 5 ++ "b") == true
+ matcher(EVIL, "a" * 50 ++ "b") == true
+ matcher(EVIL, "a" * 50) == false
+ matcher(EVIL, "b") == true
+ matcher(EVIL, "bb") == false
+ matcher("abc", "abc") == true
+ matcher("abc", "ab") == true
+ matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true
+ matcher(ONE, "") == true
+ matcher(ZERO, "") == false
+ matcher(ONE | CHAR('a'), "") == true
+ matcher(ONE | CHAR('a'), "a") == true
+  --> success
+ val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
+ size(der('a', der('a', EVIL))) == 28
+ size(der('a', der('a', der('a', EVIL)))) == 58
+ size(ders("aaaaaa".toList, EVIL)) == 8
+ size(ders(("a" * 50).toList, EVIL)) == 8
+  --> success
+ simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE
+    ...the Iterator produces the rexp
+
+      SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)
+
+    where SEQ is nested 50 times.
+
+ simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE
+    ... the Iterator produces a rexp of size 2097151
+
+ val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
+ matcher(EVIL, "a" * 1000000 ++ "b") == true
+ matcher(EVIL, "a" * 1000000) == false
+  --> success
+Overall mark for CW 9, Core Part
+6
--- a/marking4/postfix.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -2,7 +2,7 @@
 // by Edsger Dijkstra
 // ========================
 
-//object CW9b {
+object CW9a {
 
 type Toks = List[String]
 
@@ -98,6 +98,6 @@
 // compute(syard(split("5 * 7 / 2")))          // 17
 // compute(syard(split("9 + 24 / ( 7 - 3 )"))) // 15
 
-//}
+}
 
 
--- a/marking4/postfix2.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix2.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -2,7 +2,7 @@
 // including Associativity for Operators 
 // =====================================
 
-//object CW9c { // just for generating a jar file
+object CW9b { 
 
 // type of tokens
 type Toks = List[String]
@@ -97,4 +97,4 @@
 
 
 
-//}
+}
--- a/marking4/postfix_test.sh	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix_test.sh	Wed Oct 30 14:07:58 2019 +0000
@@ -7,11 +7,11 @@
 echo -e "" > $out
 
 
-echo "Below is the feedback and provisional marks for your submission" >> $out
-echo "for assignment 9 Part 2.  Please note all marks are provisional until" >> $out
-echo "ratified by the assessment board -- this is not an official" >> $out
-echo "results transcript." >> $out
-echo "" >> $out
+echo -e "Below is the feedback and provisional marks for your submission" >> $out
+echo -e "the preliminary part for assignment 9.  Please note all marks are provisional until" >> $out
+echo -e "ratified by the assessment board -- this is not an official" >> $out
+echo -e "results transcript." >> $out
+echo -e "" > $out
 
 # marks for CW9 part 2
 marks=$(( 0 ))
@@ -20,13 +20,13 @@
 # compilation tests
 
 function scala_compile {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out)   
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out)   
 }
 
 # functional tests
 
 function scala_assert {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) 
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2")  #2> /dev/null 1> /dev/null) 
 }
 
 # purity test
@@ -42,24 +42,24 @@
 
 if (scala_vars postfix.scala)
 then
-  echo "  --> test failed" | tee -a $out  
+  echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" | tee -a $out  
   tsts0=$(( 1 ))
 else
-  echo "  --> success" | tee -a $out  
+  echo -e "  --> success" | tee -a $out  
   tsts0=$(( 0 )) 
 fi
 
 # compilation test
 if  [ $tsts0 -eq 0 ]
 then    
-  echo "postfix.scala runs?" | tee -a $out
+  echo -e "postfix.scala runs?" | tee -a $out
 
   if (scala_compile postfix.scala)
   then
-    echo "  --> success" | tee -a $out
+    echo -e "  --> success" | tee -a $out
     tsts1=$(( 0 ))
   else
-    echo "  --> scala postfix.scala did not run successfully" | tee -a $out
+    echo -e "  --> SCALA DID NOT RUN postfix.scala" | tee -a $out
     tsts1=$(( 1 )) 
   fi
 else
@@ -81,7 +81,7 @@
     echo -e "  --> success" | tee -a $out
     marks=$(( marks + 1 ))
   else
-    echo -e "  --> test failed" | tee -a $out
+    echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -101,7 +101,7 @@
      echo -e "  --> success" | tee -a $out
      marks=$(( marks + 1 ))
   else
-     echo "  --> test failed" | tee -a $out
+     echo "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -115,10 +115,10 @@
 
 if (scala_vars postfix2.scala)
 then
-  echo "  --> test failed" | tee -a $out  
+  echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" | tee -a $out  
   tsts0=$(( 1 ))
 else
-  echo "  --> success" | tee -a $out  
+  echo -e "  --> success" | tee -a $out  
   tsts0=$(( 0 )) 
 fi
 
@@ -128,14 +128,14 @@
 # compilation test
 if  [ $tsts0 -eq 0 ]
 then    
-  echo "postfix2.scala runs?" | tee -a $out
+  echo -e "postfix2.scala runs?" | tee -a $out
 
   if (scala_compile postfix2.scala)
   then
-    echo "  --> success" | tee -a $out
+    echo -e "  --> success" | tee -a $out
     tsts1=$(( 0 ))
   else
-    echo "  --> scala postfix2.scala did not run successfully" | tee -a $out
+    echo -e "  --> SCALA DID NOT RUN postfix2.scala" | tee -a $out
     tsts1=$(( 1 )) 
   fi
 else
@@ -168,10 +168,10 @@
       echo -e "  --> success" | tee -a $out
       marks=$(( marks + 2 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
 ## final marks
-echo "Overall mark for CW 9, Part 2" | tee -a $out
-echo "$marks" | tee -a $out
+echo -e "Overall mark for CW 9, Preliminary Part" | tee -a $out
+echo -e "$marks" | tee -a $out
--- a/marking4/postfix_test7.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix_test7.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,3 +1,5 @@
+import CW9a._
+
 
 assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
 assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
--- a/marking4/postfix_test8.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix_test8.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,3 +1,4 @@
+import CW9a._
 
 assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
 assert(compute(syard(split("10 + 12 * 33"))) == 406)
--- a/marking4/postfix_test9.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/postfix_test9.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,3 +1,5 @@
+import CW9b._
+
 
 assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
 assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
--- a/marking4/re.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,7 +1,7 @@
-// Part 1 about Regular Expression Matching
-//==========================================
+// Core Part about Regular Expression Matching
+//=============================================
 
-//object CW9a {
+object CW9c {
 
 // Regular Expressions
 abstract class Rexp
@@ -173,4 +173,4 @@
  
 
 
-//}
+}
--- a/marking4/re_test.sh	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test.sh	Wed Oct 30 14:07:58 2019 +0000
@@ -5,32 +5,32 @@
 
 out=${1:-output}
 
-echo "" > $out
+echo -e "" > $out
 
 
-echo "Below is the feedback and provisional marks for your submission" >> $out
-echo "for assignment 9 Part 1.  Please note all marks are provisional until" >> $out
-echo "ratified by the assessment board -- this is not an official" >> $out
-echo "results transcript." >> $out
-echo "" >> $out
+echo -e "Below is the feedback and provisional marks for your submission" >> $out
+echo -e "for the core part of assignment 9.  Please note all marks are provisional until" >> $out
+echo -e "ratified by the assessment board -- this is not an official" >> $out
+echo -e "results transcript." >> $out
+echo -e "" >> $out
 
-# marks for CW9 part 1
+# marks for CW9
 marks=$(( 0 ))
 
 # compilation tests
 
 function scala_compile {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
 }
 
 # functional tests
 
 function scala_assert {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 function scala_assert_long {
-    (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+    (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 # purity test
@@ -42,14 +42,14 @@
 
 # var, return, ListBuffer test
 #
-echo "re.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
+echo -e "re.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
 
 if (scala_vars re.scala)
 then
-  echo "  --> test failed" | tee -a $out
+  echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" | tee -a $out
   tsts0=$(( 1 ))
 else
-  echo "  --> success" | tee -a $out
+  echo -e "  --> success" | tee -a $out
   tsts0=$(( 0 )) 
 fi
 
@@ -57,14 +57,14 @@
 # compilation test
 if  [ $tsts0 -eq 0 ]
 then    
-  echo "re.scala runs?" | tee -a $out
+  echo -e "re.scala runs?" | tee -a $out
 
   if (scala_compile re.scala)
   then
-    echo "  --> success" | tee -a $out
+    echo -e "  --> success" | tee -a $out
     tsts1=$(( 0 ))
   else
-    echo "  --> scala re.scala did not run successfully" | tee -a $out
+    echo -e "  --> SCALA DID NOT RUN re.scala" | tee -a $out
     tsts1=$(( 1 )) 
   fi
 else
@@ -75,21 +75,21 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " nullable(ZERO) == false" | tee -a $out
-  echo " nullable(ONE) == true" | tee -a $out
-  echo " nullable(CHAR('a')) == false" | tee -a $out
-  echo " nullable(ZERO | ONE) == true" | tee -a $out
-  echo " nullable(ZERO | CHAR('a')) == false" | tee -a $out
-  echo " nullable(ONE ~  ONE) == true" | tee -a $out
-  echo " nullable(ONE ~ CHAR('a')) == false" | tee -a $out
-  echo " nullable(STAR(ZERO)) == true" | tee -a $out
+  echo -e " nullable(ZERO) == false" | tee -a $out
+  echo -e " nullable(ONE) == true" | tee -a $out
+  echo -e " nullable(CHAR('a')) == false" | tee -a $out
+  echo -e " nullable(ZERO | ONE) == true" | tee -a $out
+  echo -e " nullable(ZERO | CHAR('a')) == false" | tee -a $out
+  echo -e " nullable(ONE ~  ONE) == true" | tee -a $out
+  echo -e " nullable(ONE ~ CHAR('a')) == false" | tee -a $out
+  echo -e " nullable(STAR(ZERO)) == true" | tee -a $out
   
   if (scala_assert "re.scala" "re_test1.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -97,33 +97,33 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " der('a', ZERO | ONE) == (ZERO | ZERO)" | tee -a $out
-  echo " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)" | tee -a $out
-  echo " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" | tee -a $out
-  echo " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
-  echo " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
-  echo "" | tee -a $out
-  echo " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
-  echo " assert(der('a', r0) == (ONE ~ \"b\") ~ \"c\")" | tee -a $out
-  echo " assert(der('b', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
-  echo " assert(der('c', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
-  echo "" | tee -a $out
-  echo " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
-  echo " assert(der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
-  echo " assert(der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\")" | tee -a $out
-  echo " assert(der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
-  echo "" | tee -a $out
-  echo " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
-  echo " assert(der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
-  echo " assert(der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
-  echo " assert(der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE))" | tee -a $out
+  echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" | tee -a $out
+  echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)" | tee -a $out
+  echo -e " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" | tee -a $out
+  echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
+  echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
+  echo -e " assert(der('a', r0) == (ONE ~ \"b\") ~ \"c\")" | tee -a $out
+  echo -e " assert(der('b', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
+  echo -e " assert(der('c', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
+  echo -e " assert(der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
+  echo -e " assert(der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\")" | tee -a $out
+  echo -e " assert(der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
+  echo -e " assert(der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
+  echo -e " assert(der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
+  echo -e " assert(der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE))" | tee -a $out
 
   if (scala_assert "re.scala" "re_test2.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -131,29 +131,29 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " simp(ZERO | ONE) == ONE" | tee -a $out
-  echo " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" | tee -a $out
-  echo " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" | tee -a $out
-  echo " simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
-  echo " simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
-  echo " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" | tee -a $out
-  echo " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" | tee -a $out
-  echo " simp(CHAR('a') | CHAR('a')) == CHAR('a')" | tee -a $out
-  echo " simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')" | tee -a $out
-  echo " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" | tee -a $out
-  echo " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
-  echo "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" | tee -a $out
-  echo " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
-  echo " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
-  echo " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
-  echo " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" tee -a $out
+  echo -e " simp(ZERO | ONE) == ONE" | tee -a $out
+  echo -e " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" | tee -a $out
+  echo -e " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" | tee -a $out
+  echo -e " simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
+  echo -e " simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
+  echo -e " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" | tee -a $out
+  echo -e " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" | tee -a $out
+  echo -e " simp(CHAR('a') | CHAR('a')) == CHAR('a')" | tee -a $out
+  echo -e " simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')" | tee -a $out
+  echo -e " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" | tee -a $out
+  echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
+  echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" | tee -a $out
+  echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
+  echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
+  echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
+  echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" tee -a $out
   
   if (scala_assert "re.scala" "re_test3.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -161,29 +161,29 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
-  echo " ders((\"a\" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" | tee -a $out
-  echo " ders(List('b'),EVIL) == ONE" | tee -a $out
-  echo " ders(List('b','b'),EVIL) == ZERO" | tee -a $out
-  echo " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" | tee -a $out
-  echo " matcher(EVIL, \"a\" * 50 ++ \"b\") == true" | tee -a $out
-  echo " matcher(EVIL, \"a\" * 50) == false" | tee -a $out
-  echo " matcher(EVIL, \"b\") == true" | tee -a $out
-  echo " matcher(EVIL, \"bb\") == false" | tee -a $out
-  echo " matcher(\"abc\", \"abc\") == true" | tee -a $out
-  echo " matcher(\"abc\", \"ab\") == true" | tee -a $out
-  echo " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" | tee -a $out
-  echo " matcher(ONE, \"\") == true" | tee -a $out
-  echo " matcher(ZERO, \"\") == false" | tee -a $out
-  echo " matcher(ONE | CHAR('a'), \"\") == true" | tee -a $out
-  echo " matcher(ONE | CHAR('a'), \"a\") == true" | tee -a $out
+  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
+  echo -e " ders((\"a\" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" | tee -a $out
+  echo -e " ders(List('b'),EVIL) == ONE" | tee -a $out
+  echo -e " ders(List('b','b'),EVIL) == ZERO" | tee -a $out
+  echo -e " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" | tee -a $out
+  echo -e " matcher(EVIL, \"a\" * 50 ++ \"b\") == true" | tee -a $out
+  echo -e " matcher(EVIL, \"a\" * 50) == false" | tee -a $out
+  echo -e " matcher(EVIL, \"b\") == true" | tee -a $out
+  echo -e " matcher(EVIL, \"bb\") == false" | tee -a $out
+  echo -e " matcher(\"abc\", \"abc\") == true" | tee -a $out
+  echo -e " matcher(\"abc\", \"ab\") == true" | tee -a $out
+  echo -e " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" | tee -a $out
+  echo -e " matcher(ONE, \"\") == true" | tee -a $out
+  echo -e " matcher(ZERO, \"\") == false" | tee -a $out
+  echo -e " matcher(ONE | CHAR('a'), \"\") == true" | tee -a $out
+  echo -e " matcher(ONE | CHAR('a'), \"a\") == true" | tee -a $out
   
   if (scala_assert "re.scala" "re_test4.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -192,18 +192,18 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out  
-  echo " size(der('a', der('a', EVIL))) == 28" | tee -a $out
-  echo " size(der('a', der('a', der('a', EVIL)))) == 58" | tee -a $out
-  echo " size(ders(\"aaaaaa\".toList, EVIL)) == 8" | tee -a $out
-  echo " size(ders((\"a\" * 50).toList, EVIL)) == 8" | tee -a $out
+  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out  
+  echo -e " size(der('a', der('a', EVIL))) == 28" | tee -a $out
+  echo -e " size(der('a', der('a', der('a', EVIL)))) == 58" | tee -a $out
+  echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 8" | tee -a $out
+  echo -e " size(ders((\"a\" * 50).toList, EVIL)) == 8" | tee -a $out
   
   if (scala_assert "re.scala" "re_test5.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
@@ -213,33 +213,33 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE" | tee -a $out
-  echo "    ...the Iterator produces the rexp" | tee -a $out
-  echo "" | tee -a $out
-  echo "      SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)" | tee -a $out
-  echo "" | tee -a $out
-  echo "    where SEQ is nested 50 times." | tee -a $out  
-  echo "" | tee -a $out
-  echo " simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE" | tee -a $out
-  echo "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
-  echo "" | tee -a $out
-  echo " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
-  echo " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
-  echo " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
+  echo -e " simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE" | tee -a $out
+  echo -e "    ...the Iterator produces the rexp" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e "      SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e "    where SEQ is nested 50 times." | tee -a $out  
+  echo -e "" | tee -a $out
+  echo -e " simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE" | tee -a $out
+  echo -e "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
+  echo -e "" | tee -a $out
+  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
+  echo -e " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
+  echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
 
   
   if (time scala_assert_long "re.scala" "re_test6.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
 
 
 ## final marks
-echo "Overall mark for CW 9, Part 1" | tee -a $out
-echo "$marks" | tee -a $out
+echo -e "Overall mark for CW 9, Core Part" | tee -a $out
+echo -e "$marks" | tee -a $out
 
 
--- a/marking4/re_test1.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test1.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,3 +1,4 @@
+import CW9c._
 
 assert(nullable(ZERO) == false)
 assert(nullable(ONE) == true)
--- a/marking4/re_test2.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test2.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,3 +1,4 @@
+import CW9c._
 
 assert(der('a', ZERO | ONE) == (ZERO | ZERO))
 assert(der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE))
--- a/marking4/re_test3.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test3.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,4 +1,4 @@
-
+import CW9c._
 
 
 assert(simp(ZERO | ONE) == ONE)
--- a/marking4/re_test4.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test4.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,4 +1,4 @@
-
+import CW9c._
 
 val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
 
--- a/marking4/re_test5.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test5.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,4 +1,4 @@
-
+import CW9c._ 
 val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
 
 assert(size(der('a', der('a', EVIL_urban))) == 28)
--- a/marking4/re_test6.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/marking4/re_test6.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,4 +1,4 @@
-
+import CW9c._
 
 val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
 
--- a/marking4/tails	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#!/bin/sh
-###set -e
-
-trap "exit" INT
-
-files=${1:-assignment20189-*}
-
-for sd in $files; do
-  cd $sd
-  #echo $sd
-  marksone=$(( `tail -1 output` ))
-  markstwo=$(( `tail -1 output1` ))
-  if [ "$marksone" != "$markstwo" ]; then
-      echo $sd + "is different"
-  fi
-  cd ..
-done
-
-
--- a/templates4/postfix.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/templates4/postfix.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -2,6 +2,7 @@
 // by Edsger Dijkstra
 // ========================
 
+object CW9a {
 
 // type of tokens
 type Toks = List[String]
@@ -19,7 +20,7 @@
 def split(s: String) : Toks = s.split(" ").toList
 
 
-// (6) Implement below the shunting yard algorithm. The most
+// (1) Implement below the shunting yard algorithm. The most
 // convenient way to this in Scala is to implement a recursive 
 // function and to heavily use pattern matching. The function syard 
 // takes some input tokens as first argument. The second and third 
@@ -56,7 +57,7 @@
 //syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) // 3 4 5 + +
 
  
-// (7) Implement a compute function that evaluates an input list
+// (2) Implement a compute function that evaluates an input list
 // in postfix notation. This function takes a list of tokens
 // and a stack as argumenta. The function should produce the 
 // result as an integer using the stack. You can assume 
@@ -74,6 +75,6 @@
 // compute(syard(split("5 * 7 / 2")))          // 17
 // compute(syard(split("9 + 24 / ( 7 - 3 )"))) // 15
 
+}
 
 
-
--- a/templates4/postfix2.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/templates4/postfix2.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -2,6 +2,9 @@
 // including Associativity for Operators 
 // =====================================
 
+object CW9b {
+
+
 // type of tokens
 type Toks = List[String]
 
@@ -32,7 +35,7 @@
 // the operations in the basic version of the algorithm
 val ops = List("+", "-", "*", "/", "^")
 
-// (8) Implement the extended version of the shunting yard algorithm.
+// (3) Implement the extended version of the shunting yard algorithm.
 // This version should properly account for the fact that the power 
 // operation is right-associative. Apart from the extension to include
 // the power operation, you can make the same assumptions as in 
@@ -45,7 +48,7 @@
 // syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3"))  // 3 4 8 * 5 1 - 2 3 ^ ^ / +
 
 
-// (9) Implement a compute function that produces a Long(!) for an
+// (4) Implement a compute function that produces a Long(!) for an
 // input list of tokens in postfix notation.
 
 //def compute(toks: Toks, st: List[Long] = Nil) : Long = ...
@@ -63,3 +66,4 @@
 // compute(syard(split("( 4 ^ 3 ) ^ 2")))  // 4096
 // compute(syard(split("( 3 + 1 ) ^ 2 ^ 3")))   // 65536
 
+}
--- a/templates4/re.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/templates4/re.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -1,5 +1,7 @@
-// Part 1 about Regular Expression Matching
-//==========================================
+// Core Part about Regular Expression Matching
+//=============================================
+
+object CW9c {
 
 // Regular Expressions
 abstract class Rexp
@@ -37,7 +39,7 @@
   def ~ (r: String) = SEQ(s, r)
 }
 
-// (1) Complete the function nullable according to
+// (5) Complete the function nullable according to
 // the definition given in the coursework; this 
 // function checks whether a regular expression
 // can match the empty string and Returns a boolean
@@ -46,7 +48,7 @@
 //def nullable (r: Rexp) : Boolean = ...
 
 
-// (2) Complete the function der according to
+// (6) Complete the function der according to
 // the definition given in the coursework; this
 // function calculates the derivative of a 
 // regular expression w.r.t. a character.
@@ -54,7 +56,7 @@
 //def der (c: Char, r: Rexp) : Rexp = ...
 
 
-// (3) Complete the simp function according to
+// (7) Complete the simp function according to
 // the specification given in the coursework; this
 // function simplifies a regular expression from
 // the inside out, like you would simplify arithmetic 
@@ -64,7 +66,7 @@
 //def simp(r: Rexp) : Rexp = ... 
 
 
-// (4) Complete the two functions below; the first 
+// (8) Complete the two functions below; the first 
 // calculates the derivative w.r.t. a string; the second
 // is the regular expression matcher taking a regular
 // expression and a string and checks whether the
@@ -75,7 +77,7 @@
 //def matcher(r: Rexp, s: String): Boolean = ...
 
 
-// (5) Complete the size function for regular
+// (9) Complete the size function for regular
 // expressions according to the specification 
 // given in the coursework.
 
@@ -132,3 +134,4 @@
 
 */
 
+}
--- a/testing4/bf.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,457 +0,0 @@
-// Part 2 about an Interpreter for the Brainf*** language
-//========================================================
-
-object CW8b {
-
-type Mem = Map[Int, Int]
-
-// (2a) Complete the functions for safely reading  
-// and writing brainf*** memory. Safely read should
-// Return the value stored in the Map for a given memory
-// pointer, if it exists; otherwise it Returns 0. The
-// writing function generates a new Map with the
-// same data, except at the given memory pointer the
-// value v is stored.
-
-
-def sread(mem: Mem, mp: Int) : Int = 
-  mem.getOrElse(mp, 0)
-
-def write(mem: Mem, mp: Int, v: Int) : Mem =
-  mem.updated(mp, v)
-
-
-// (2b) Implement the two jumping instructions in the 
-// brainf*** language. In jumpRight, given a program and 
-// a program counter move the program counter to the right 
-// until after the *matching* ]-command. Similarly, 
-// jumpLeft implements the move to the left to just after
-// the *matching* [--command.
-
-def jumpRight(prog: String, pc: Int, level: Int) : Int = {
-  if (prog.length <= pc) pc 
-  else (prog(pc), level) match {
-    case (']', 0) => pc + 1
-    case (']', l) => jumpRight(prog, pc + 1, l - 1)
-    case ('[', l) => jumpRight(prog, pc + 1, l + 1)
-    case (_, l) => jumpRight(prog, pc + 1, l)
-  }
-}
-
-def jumpLeft(prog: String, p: Int, level: Int) : Int = {
-  if (p < 0) p 
-  else (prog(p), level) match {
-    case ('[', 0) => p + 1
-    case ('[', l) => jumpLeft(prog, p - 1, l - 1)
-    case (']', l) => jumpLeft(prog, p - 1, l + 1)
-    case (_, l) => jumpLeft(prog, p - 1, l)
-  }
-}
-
-//jumpLeft("[******]***", 7, 0)
-
-// (2c) Complete the run function that interpretes (runs) a brainf***
-// program: the arguments are a program, a program counter,
-// a memory counter and a brainf*** memory. It Returns the
-// memory at the stage when the excution of the brainf*** program
-// finishes. The interpretation finishes once the program counter
-// pc is pointing to something outside the program string.
-// If the pc points to a character inside the program, the pc, 
-// memory pointer and memory need to be updated according to 
-// rules of the brainf*** language. Then, recursively, run 
-// function continues with the command at the new program
-// counter. 
-// Implement the start function that calls run with the program
-// counter and memory counter set to 0.
-
-def run(prog: String, pc: Int, mp: Int, mem: Mem) : Mem = {
-  if (0 <= pc && pc < prog.length) { 
-    val (new_pc, new_mp, new_mem) = prog(pc) match {
-      case '>' => (pc + 1, mp + 1, mem)
-      case '<' => (pc + 1, mp - 1, mem)
-      case '+' => (pc + 1, mp, write(mem, mp, sread(mem, mp) + 1))
-      case '-' => (pc + 1, mp, write(mem, mp, sread(mem, mp) - 1))
-      case '.' => { print(sread(mem, mp).toChar); (pc + 1, mp, mem) }
-      case ',' => (pc + 1, mp, write(mem, mp, Console.in.read().toByte))
-      case '['  => 
-	if (sread(mem, mp) == 0) (jumpRight(prog, pc + 1, 0), mp, mem) else (pc + 1, mp, mem) 
-      case ']'  => 
-	if (sread(mem, mp) != 0) (jumpLeft(prog, pc - 1, 0), mp, mem) else (pc + 1, mp, mem) 
-      case _ => (pc + 1, mp, mem)
-    }		     
-    run(prog, new_pc, new_mp, new_mem)	
-  }
-  else mem
-}
-
-def start(prog: String, m: Mem) = run(prog, 0, 0, m)
-
-// some sample programs collected from the Internet
-//==================================================
-
-
-/*
-// first some contrived (small) programs
-
-// clears the 0-cell
-start("[-]", Map(0 -> 100)) 
-
-// copies content of the 0-cell to 1-cell
-start("[->+<]", Map(0 -> 10))
-
-// copies content of the 0-cell to 2-cell and 4-cell
-start("[>>+>>+<<<<-]", Map(0 -> 42))
-
-
-// prints out numbers 0 to 9
-start("""+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]""", Map())
-
-
-// some more "useful" programs
-
-// hello world program 1
-start("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
-       ..+++.>>.<-.<.+++.------.--------.>>+.>++.""", Map())
-
-// hello world program 2
-start("""++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>+
-      +.<<+++++++++++++++.>.+++.------.--------.>+.>.""", Map())
-
-
-// draws the Sierpinski triangle
-start("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
-      ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
-      ]>.>+[>>]>+]""", Map())
-
-//fibonacci numbers below 100
-start("""+++++++++++
-      >+>>>>++++++++++++++++++++++++++++++++++++++++++++
-      >++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
-      +<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
-      <-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
-      -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
-      >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
-      +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
-      ++++++++++++++++++++++++++++++++++++++++++++.[-]<<
-      <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
-      [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]""", Map())
-
-
-//outputs the square numbers up to 10000
-start("""++++[>+++++<-]>[<+++++>-]+<+[
-    >[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+
-    >>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]
-    <<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]""", Map())
-
-//collatz numbers (need to be typed in)
-start(""">,[[----------[
-      >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<]
-      ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],<]>]>>>++>+>>[
-      <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>]
-      >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]]
-      >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>>
-      ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<,]""", Map())
-
-
-// infinite collatz (never stops)
-start(""">>+>+<[[->>[>>]>>>[>>]+[<<]<<<[<<]>[>[>>]>>+>[>>]<+<[<<]<<<[<
-      <]>-]>[>>]>>[<<<<[<<]>+>[>>]>>-]<<<<[<<]+>>]<<[+++++[>+++++++
-      +<-]>.<++++++[>--------<-]+<<]>>[>>]+[>>>>[<<+>+>-]<-[>+<-]+<
-      [<<->>-[<<+>>[-]]]>>>[<<<+<<+>>>>>-]<<<[>>>+<<<-]<<[[-]>+>>->
-      [<+<[<<+>>-]<[>+<-]<[>+<-]>>>>-]<[>+<-]+<[->[>>]<<[->[<+++>-[
-      <+++>-[<+++>-[<[-]++>>[-]+>+<<-[<+++>-[<+++>-[<[-]+>>>+<<-[<+
-      ++>-[<+++>-]]]]]]]]]<[>+<-]+<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<
-      +>-[<+>-[<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-[<+>-]]]]]]]]]]]<[>+<-
-      ]+>>]<<[<<]>]<[->>[->+>]<[-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<-
-      >>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>
-      -[<->>+<-[<+>-[<->>+<-[<+>-]]]]]]]]]]]]]]]]]]]>[<+>-]<+<[<+++
-      +++++++>-]<]>>[<+>->>]<<[>+>+<<-]>[<+>-]+>[<->[-]]<[-<<-]<<[<
-      <]]++++++[>+++++++<-]>++.------------.[-]>[>>]<<[+++++[>+++++
-      +++<-]>.<++++++[>--------<-]+<<]+<]>[<+>-]<]>>>[>>]<<[>[-]<-<
-      <]++++++++++.[-]<<<[<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<+>-[<+>-
-      [<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-]]]]]]]]]]<[>+<-]+>>]<<[<<]>>]""", Map())
-
-
-start("""+++++[>+++++++++<-],[[>--.++>+<<-]>+.->[<.>-]<<,]""", Map())
-
-*/ 
-
-
-def splice(cs: List[Char], acc: List[(Char, Int)]) : List[(Char, Int)] = (cs, acc) match {
-  case (Nil, acc) => acc
-  case (c :: cs, Nil) => splice(cs, List((c, 1)))
-  case (c :: cs, (d, n) :: acc) => 
-    if (c == d) splice(cs, (c, n + 1) :: acc)
-    else splice(cs, (c, 1) :: (d, n) :: acc)
-}
-
-def spl(s: String) = splice(s.toList, Nil).reverse
-
-
-// simple instructions
-def instr(c: Char) : String = c match {
-  case '>' => "ptr++;"
-  case '<' => "ptr--;"
-  case '+' => "(*ptr)++;"
-  case '-' => "(*ptr)--;"
-  case '.' => "putchar(*ptr);"
-  case ',' => "*ptr = getchar();\n"
-  case '['  => "while(*ptr){"
-  case ']'  => "}"
-  case _ => ""
-}
-
-def instrs(prog: String) : String =
-  prog.toList.map(instr(_)).mkString
-
-
-//optimised instructions
-
-def instr2(c: Char, n: Int) : String = c match {
-  case '>' => "ptr += " + n.toString + ";"
-  case '<' => "ptr -= " + n.toString + ";"
-  case '+' => "(*ptr) += " + n.toString + ";"
-  case '-' => "(*ptr) -= " + n.toString + ";"
-  case '.' => "putchar(*ptr);" * n
-  case ',' => "*ptr = getchar();\n" * n
-  case '['  => "while(*ptr){" * n
-  case ']'  => "}" * n
-  case _ => ""
-}
-
-def instrs2(prog: String) : String =
-  spl(prog).map{ case (c, n) => instr2(c, n) }.mkString
-
-
-// peephole optimisers are at
-// https://github.com/Wilfred/bfc#peephole-optimisations
-// http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck.html
-
-def compile_str(prog: String) : String = {
-  "#include <string.h>\n" ++
-  "#include <stdio.h>\n" ++
-  "char field[30000];\n" ++
-  "char *ptr = &field[15000];" ++
-  "int main()\n{\n" ++
-  "memset(field, '\\0', 30000);\n" ++
-  instrs2(prog) ++
-  "\n return 0;\n}"
-}
-
-def compile(name: String, prog: String) = {
-  val fw = new java.io.FileWriter(name + ".c") 
-  val is = compile_str(prog)
-  println(is)
-  fw.write(is) 
-  fw.close()
-}
-
-import sys.process._
-
-def compile_run(prog: String) = {
-  compile("tmp", prog)
-  "gcc -O3 -o tmp tmp.c".!
-  "./tmp".!
-  ()
-}
-
-
-compile("test.bf", """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
-       ..+++.>>.<-.<.+++.------.--------.>>+.>++.""")
-
-compile_run("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[
-      ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
-      ]>.>+[>>]>+]""")
-
-compile_run("""      A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
-+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
->>>>>>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+>+>++<[>[<+++>-
-
-  >>>>>
-  >+>+>+>+>++<[>[<+++>-
-
-    >>>>>
-    >+>+>+>+>++<[>[<+++>-
-
-      >>>>>
-      >+>+>+>+>++<[>[<+++>-
-
-        >>>>>
-        +++[->+++++<]>[-]<
-        <<<<<
-
-      ]<<]>[-]
-      <<<<<
-
-    ]<<]>[-]
-    <<<<<
-
-  ]<<]>[-]
-  <<<<<
-
-]<<]>.""")
-
-// benchmarks
-compile_run(""">++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++
-[>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++
-++++++++[>++++++++++[>++++++++++[>++++++++++[>+
-+++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.""")
-
-//
-compile_run("""++++[>++++<-]>[>+>++>[+++++++>]+++[<]>-]>>>>>>>>-.
-<<<<.<..+++.<.>>>>.<<<.+++.------.>-.<<+.<------.""")
-
-compile_run("""++++++++[->-[->-[->-[-]<]<]<]
->++++++++[<++++++++++>-]<[>+>+<<-]>-.>-----.>""")
-
-
-
-
-// register to BF compiler
-// https://gergo.erdi.hu/blog/2010-09-06-from_register_machines_to_brainfuck,_part_1/
-}
--- a/testing4/bf1a_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-//import scala.language.reflectiveCalls
-
-//lazy val f = Future {
-  import CW8b._
-
-  assert(sread(Map(), 2) == 0)
-  assert(sread(Map(2 -> 1), 2) == 1)
-  assert(write(Map(), 1, 2) == Map(1 -> 2))
-  assert(write(Map(1 -> 0), 1, 2) == Map(1 -> 2))
-//}
-
-//Await.result(f, 120 second)
--- a/testing4/bf1b_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-//import scala.language.reflectiveCalls
-
-//lazy val f = Future {
-  import CW8b._
-
-  assert(jumpRight("[******]***", 1, 0) == 8)
-  assert(jumpRight("[**[*]*]***", 1, 0) == 8)
-  assert(jumpRight("[**[*]*]***", 1, 0) == 8)  
-  assert(jumpRight("[**[***]***", 1, 0) == 11)
-  assert(jumpRight("[*[][]*]***", 1, 0) == 8)
-  assert(jumpLeft("[******]***", 6, 0) == 1)
-  assert(jumpLeft("[******]***", 7, 0) == -1)
-  assert(jumpLeft("[*[][]*]***", 6, 0) == 1)
-//}
-
-//Await.result(f, 120 second)
--- a/testing4/bf1c_test.scala	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-//import scala.language.reflectiveCalls
-
-//lazy val f = Future {
-  import CW8b._
-
-  assert(start("[-]", Map(0 -> 100)) == Map(0 -> 0))
-  assert(start("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
-  assert(start("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
-  assert(start("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]
-       <-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.""", Map()) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
-
-//}
-
-//Await.result(f, 120 second)
--- a/testing4/bf_test.sh	Wed Oct 30 12:47:10 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-#!/bin/bash
-set -e
-
-out=${1:-output}
-
-echo "" > $out
-
-echo "Below is the feedback for your submission of CW 8, Part 2." >> $out
-echo "" >> $out
-
-
-# compilation tests
-
-function scala_compile {
-  (ulimit -t 30 -m 1024000 ; scala "$1" 2>> $out 1>> $out) 
-}
-
-# functional tests
-
-function scala_assert {
-  (ulimit -t 30 -m 1024000 ; scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
-}
-
-# purity test
-
-function scala_vars {
-   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
-}
-
-
-# var, return, ListBuffer test
-#
-echo "bf.scala does not contain vars, returns etc?" >> $out
-
-if (scala_vars bf.scala)
-then
-  echo "  --> fail" >> $out
-  tsts0=$(( 1 ))
-else
-  echo "  --> success" >> $out
-  tsts0=$(( 0 )) 
-fi
-
-
-# compilation test
-if  [ $tsts0 -eq 0 ]
-then    
-  echo "bf.scala runs?" >> $out
-
-  if (scala_compile bf.scala)
-  then
-    echo "  --> success" >> $out
-    tsts1=$(( 0 ))
-  else
-    echo "  --> scala bf.scala did not run successfully" >> $out
-    tsts1=$(( 1 )) 
-  fi
-else
-  tsts1=$(( 1 ))     
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-  echo " sread(Map(), 2) == 0" >> $out
-  echo " sread(Map(2 -> 1), 2) == 1" >> $out  
-  echo " write(Map(), 1, 2) == Map(1 -> 2)" >> $out
-  echo " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" >> $out
-  
-  if (scala_assert "bf.scala" "bf1a_test.scala")
-  then
-    echo "  --> success" >> $out
-  else
-    echo "  --> test failed" >> $out
-  fi
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-    echo " jumpRight(\"[******]***\", 1, 0) == 8" >> $out
-    echo " jumpRight(\"[**[*]*]***\", 1, 0) == 8" >> $out
-    echo " jumpRight(\"[**[*]*]***\", 1, 0) == 8" >> $out
-    echo " jumpRight(\"[**[***]***\", 1, 0) == 11" >> $out
-    echo " jumpRight(\"[*[][]*]***\", 1, 0) == 8" >> $out
-    echo " jumpLeft(\"[******]***\", 6, 0) == 1" >> $out
-    echo " jumpLeft(\"[******]***\", 7, 0) == -1" >> $out
-    echo " jumpLeft(\"[*[][]*]***\", 6, 0) == 1" >> $out
-  
-  if (scala_assert "bf.scala" "bf1b_test.scala")
-  then
-    echo "  --> success" >> $out
-  else
-    echo "  --> test failed" >> $out
-  fi
-fi
-
-
-
-if [ $tsts1 -eq 0 ]
-then
-  echo " start(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" >> $out
-  echo " start(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" >> $out
-  echo " start(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" >> $out
-  echo " start({{hello world prg 1}}, Map()) == " >> $out
-  echo "        Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" >> $out
-
-  if (scala_assert "bf.scala" "bf1c_test.scala")
-  then
-    echo "  --> success" >> $out
-  else
-    echo "  --> test failed" >> $out
-  fi
-fi
-
-
-
-