--- a/scala/abacus.scala Fri Mar 08 11:31:04 2013 +0000
+++ b/scala/abacus.scala Sun Mar 10 07:10:50 2013 +0000
@@ -35,16 +35,16 @@
case Goto(l) => if (l == old_jump) Goto(jump) else Goto(l)
}))
- def step(cf: AConfig) : AConfig = (nth_of(p, cf.s), cf.s) match {
- case (None, _) => cf
- case (Some(Inc(n)), s) => AConfig(s + 1, cf.regs + (n -> (dget(cf.regs, n) + 1)))
- case (Some(Dec(n, l)), s) => {
+ def step(cf: AConfig) : AConfig = nth_of(p, cf.s) match {
+ case None => cf
+ case Some(Inc(n)) => AConfig(cf.s + 1, cf.regs + (n -> (dget(cf.regs, n) + 1)))
+ case Some(Dec(n, l)) => {
if (dget(cf.regs, n) == 0) AConfig(l, cf.regs)
- else AConfig(s + 1, cf.regs + (n -> (dget(cf.regs, n) - 1)))
+ else AConfig(cf.s + 1, cf.regs + (n -> (dget(cf.regs, n) - 1)))
}
- case (Some(Goto(l)), _) => AConfig(l, cf.regs)
- }
-
+ case Some(Goto(l)) => AConfig(l, cf.regs)
+ }
+
def steps(cf: AConfig, n: Int) : AConfig = n match {
case 0 => cf
case n => steps(step(cf), n - 1)