--- a/scala/ex.scala Thu Feb 21 16:07:40 2013 +0000
+++ b/scala/ex.scala Fri Feb 22 14:31:34 2013 +0000
@@ -4,16 +4,16 @@
import comp1._
// Turing machine examples
-val TMCopy = TM(List((WBk, 5), (R, 2), (R, 3), (R, 2), (WOc, 3),
- (L, 4), (L, 4), (L, 5), (R, 11), (R, 6),
- (R, 7), (WBk, 6), (R, 7), (R, 8), (WOc, 9),
- (R, 8), (L, 10), (L, 9), (L, 10), (L, 5),
- (L, 0), (R, 12), (WOc, 13), (L, 14), (R, 12),
- (R, 12), (L, 15), (WBk, 14), (R, 0), (L, 15)))
+val TMCopy = TM((WBk, 5), (R, 2), (R, 3), (R, 2), (WOc, 3),
+ (L, 4), (L, 4), (L, 5), (R, 11), (R, 6),
+ (R, 7), (WBk, 6), (R, 7), (R, 8), (WOc, 9),
+ (R, 8), (L, 10), (L, 9), (L, 10), (L, 5),
+ (L, 0), (R, 12), (WOc, 13), (L, 14), (R, 12),
+ (R, 12), (L, 15), (WBk, 14), (R, 0), (L, 15))
println("TMCopy: " + (TMCopy.run(Tape(3))))
println("TMfindnth: " + (TMFindnth(3).run(Tape(1,2,3,4,5))))
-println("TMMopup: " + (TMMopup(3).run(Tape(1,2,3,4,5))))
+println("TMMopup: " + (TMMopup(3).run(Tape(1,2,3,4,5))))
// Abacus machine examples
@@ -32,10 +32,10 @@
Copy(tmp2, out, -1).shift(10, -1). adjust(-1, 1)
}
-println("Copy: 3 " + (Copy(0, 1, -1).run(Map(0 -> 3, 1 -> 0))))
-println("Plus: 3 + 4 " + (Plus(0, 1, 2, -1).run(Map(0 -> 3, 1 -> 4, 2 -> 0))))
-println("Mult: 3 * 5 " + (Mult(0, 1, 2, 3, -1).run(Map(0 -> 3, 1 -> 5, 2 -> 0, 3 -> 0))))
-println("Expo: 3 ^ 4 " + (Expo(0, 1, 2, 3, 4, -1).run(Map(0 -> 4, 1 -> 3, 2 -> 0, 3 -> 0, 4 -> 0))))
+println("Copy 3: " + (Copy(0, 1, -1).run(Map(0 -> 3, 1 -> 0))))
+println("Plus 3 + 4: " + (Plus(0, 1, 2, -1).run(Map(0 -> 3, 1 -> 4, 2 -> 0))))
+println("Mult 3 * 5: " + (Mult(0, 1, 2, 3, -1).run(Map(0 -> 3, 1 -> 5, 2 -> 0, 3 -> 0))))
+println("Expo 3 ^ 4: " + (Expo(0, 1, 2, 3, 4, -1).run(Map(0 -> 4, 1 -> 3, 2 -> 0, 3 -> 0, 4 -> 0))))
// Abacus-to-TM translation examples