main_solution5/bf.scala
changeset 400 e48ea8300b2d
parent 348 b5b6ed38c2f2
child 420 4edc1a308652
--- a/main_solution5/bf.scala	Sat Nov 06 00:06:39 2021 +0000
+++ b/main_solution5/bf.scala	Mon Nov 08 00:17:50 2021 +0000
@@ -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
 //-----------------------------