tuning
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 01 Mar 2013 11:17:50 +0000
changeset 207 b93ec66cf4bb
parent 206 17d80924af53
child 208 3267acc1f97f
tuning
paper.pdf
scala/comp1.scala
scala/ex.scala
Binary file paper.pdf has changed
--- a/scala/comp1.scala	Fri Mar 01 11:16:30 2013 +0000
+++ b/scala/comp1.scala	Fri Mar 01 11:17:50 2013 +0000
@@ -56,7 +56,7 @@
 
 def compile_Goto(s: Int) = TMGoto.shift(s - 1)
 
-def compile(p: AProg, s: Int, i: AInst) = i match {
+def compile_abc(p: AProg, s: Int, i: AInst) = i match {
   case Inc(n) => compile_Inc(s, n)
   case Dec(n, e) => compile_Dec(s, n, address(p, e))
   case Goto(e) => compile_Goto(address(p, e))
@@ -64,7 +64,7 @@
 
 // component TMs for each instruction
 def TMs(p: AProg) = 
-  p.zipWithIndex.map{case (i, n) => compile(p, address(p, n), i)}
+  p.zipWithIndex.map{case (i, n) => compile_abc(p, address(p, n), i)}
 
 def toTM(p: AProg) = TMs(p).reduceLeft(_ ++ _)
     
--- a/scala/ex.scala	Fri Mar 01 11:16:30 2013 +0000
+++ b/scala/ex.scala	Fri Mar 01 11:17:50 2013 +0000
@@ -87,11 +87,11 @@
 
 
 println(Const(1))
-println(compile_rec(Const(1))._1)
 println(compile_rec(Const(1)))
 println(compile_rec(Const(1))._1.run(Map(0 -> 1, 1 -> 1, 2 -> 0)))
+println(toTM(compile_rec(Const(1))._1.p).run(Tape(1, 1, 0)))
 println(Add)
 println(compile_rec(Add)._1)
-println(compile_rec(Add))
+println(toTM(compile_rec(Add)._1.p).run(Tape(3, 4, 0)))
 println(compile_rec(Add)._1.run(Map(0 -> 3, 1 -> 8, 2 -> 0)))
 //compile_rec(Add)._1.run(Map(0 -> 3, 1 -> 4, 2 -> 0))