main_marking5/bfc.scala
changeset 424 daf561a83ba6
parent 392 97ecdc8cb61b
child 463 0315d9983cd0
--- a/main_marking5/bfc.scala	Thu Jan 13 12:55:03 2022 +0000
+++ b/main_marking5/bfc.scala	Mon Apr 11 23:55:27 2022 +0100
@@ -1,7 +1,7 @@
 // Part 2 about a "Compiler" for the Brainf*** language
 //======================================================
 
-object CW10b {
+object M5b {
 
 // !!! Copy any function you need from file bf.scala !!!
 //
@@ -170,14 +170,14 @@
 // that is write(mem, mp, 0). 
 //
 // The easiest way to modify a string in this way is to use the regular
-// expression """[^<>+-.\[\]@*#]""", which recognises everything that is 
+// expression """[^<>+-.\[\]""", which recognises everything that is 
 // not a bf-command and replace it by the empty string. Similarly the
 // regular expression """\[-\]""" finds all occurences of [-] and 
 // by using the Scala method .replaceAll you can repplace it with the 
 // string "0" standing for the new bf-command.
 
 def optimise(s: String) : String = {
-  s.replaceAll("""[^<>+-.\[\]@*#]""","")
+  s.replaceAll("""[^<>+-.\[\]]""","")
    .replaceAll("""\[-\]""", "0")
 }
 
@@ -212,9 +212,10 @@
 
 //println(optimise(load_bff("collatz.bf")))
 //optimise(load_bff("benchmark.bf"))          // should have inserted 0's
-//optimise(load_bff("mandelbrot.bf")).length  // => 11203
+//optimise(load_bff("mandelbrot.bf")).length  // => 11205
  
 //time_needed(1, run3(load_bff("benchmark.bf")))
+//time_needed(1, run3(load_bff("mandelbrot.bf")))