main_marking5/bf.scala
changeset 424 daf561a83ba6
parent 392 97ecdc8cb61b
child 463 0315d9983cd0
--- a/main_marking5/bf.scala	Thu Jan 13 12:55:03 2022 +0000
+++ b/main_marking5/bf.scala	Mon Apr 11 23:55:27 2022 +0100
@@ -2,7 +2,7 @@
 // the Brainf***++ language
 //==============================================
 
-object CW10a {  
+object M5a {  
 
 
 // representation of Bf memory 
@@ -96,18 +96,11 @@
       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 ',' => (pc + 1, mp, write(mem, mp, scala.io.StdIn.readByte()))
       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) 
  
-      // new commands
-      case '@' => (pc + 1, mp, write(mem, sread(mem, mp), sread(mem, mp - 1)))
-      case '*' => (pc + 1, mp, write(mem, mp, sread(mem, mp) * sread(mem, mp -1)))
-      case '#' => { println(s"${sread(mem, mp)}"); (pc + 1, mp, mem) }
-      
       case _ => (pc + 1, mp, mem)
     }		     
     compute(prog, new_pc, new_mp, new_mem)	
@@ -142,15 +135,6 @@
 // prints out numbers 0 to 9
 //run("""+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]""")
 
-// bf++ program calculating the cube-function, 10 * 10 * 10 = 1000
-//run("""++++++++++#>+***#""")           // Map(0 -> 10, 1 -> 1000)
-
-
-// bf++ program copies 3 from 0-cell to to cells 1, 4, 5, 6 and 7
-// (note that because of how the program wprks cell 1 will contain 7) 
-//run("""+++>+@+@+@+@+@""")   // Map(0 -> 3, 1 -> 7, 4 -> 3, 5 -> 3, 6 -> 3, 7 -> 3)
-
-
 
 // some more "useful" programs
 //-----------------------------
@@ -225,3 +209,7 @@
 //run(load_bff("collatz.bf"))
 
 }
+
+
+//M5a.run(M5a.load_bff("mandelbrot.bf"))
+//M5a.run(M5a.load_bff("collatz.bf"))