--- a/scala/abacus.scala Thu Feb 21 16:07:40 2013 +0000
+++ b/scala/abacus.scala Fri Feb 22 14:31:34 2013 +0000
@@ -2,7 +2,7 @@
import lib._
-// Abacus machines
+// Abacus instructions
sealed abstract class AInst
case class Inc(n: Int) extends AInst
case class Dec(n: Int, l: Int) extends AInst
@@ -11,10 +11,13 @@
type AProg = List[AInst]
type Regs = Map[Int, Int]
+// Abacus configurations
case class AConfig(s: Int, regs: Regs)
+// Abacus machines
case class Abacus(p: AProg) {
+ //simple composition
def ++ (that: Abacus) = Abacus(this.p ::: that.p)
def shift(offset: Int, jump: Int) = Abacus(p.map(_ match {