--- a/main_solution5/bfc.scala Mon Nov 06 14:18:26 2023 +0000
+++ b/main_solution5/bfc.scala Mon Nov 06 21:26:57 2023 +0000
@@ -60,10 +60,8 @@
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 '[' =>
- 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 '[' => 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)
}
compute(prog, new_pc, new_mp, new_mem)
@@ -143,10 +141,8 @@
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 '[' =>
- if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
- case ']' =>
- if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case '[' => if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case ']' => if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
case _ => (pc + 1, mp, mem)
}
compute2(pg, tb, new_pc, new_mp, new_mem)
@@ -191,10 +187,8 @@
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 '[' =>
- if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
- case ']' =>
- if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case '[' => if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case ']' => if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
case _ => (pc + 1, mp, mem)
}
compute3(pg, tb, new_pc, new_mp, new_mem)
@@ -278,10 +272,8 @@
case '+' => (pc + 2, mp, write(mem, mp, sread(mem, mp) + (pg(pc + 1) - '@')))
case '-' => (pc + 2, mp, write(mem, mp, sread(mem, mp) - (pg(pc + 1) - '@')))
case '.' => { print(sread(mem, mp).toChar); (pc + 1, mp, mem) }
- case '[' =>
- if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
- case ']' =>
- if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case '[' => if (sread(mem, mp) == 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
+ case ']' => if (sread(mem, mp) != 0) (tb(pc), mp, mem) else (pc + 1, mp, mem)
case _ => (pc + 1, mp, mem)
}
compute4(pg, tb, new_pc, new_mp, new_mem)