--- a/scala/ex.scala Fri Mar 01 23:46:02 2013 +0000
+++ b/scala/ex.scala Sat Mar 02 10:42:39 2013 +0000
@@ -100,14 +100,36 @@
println("Power(3, 4) " + test_comp2(Power, 3, 4))
println("Minus(30, 4) " + test_comp2(Minus, 30, 4))
println("Fact(5) " + test_comp2(Fact, 5))
-println("Prime(5) " + test_comp2(Prime, 5))
-println("Prime(6) " + test_comp2(Prime, 6))
+//println("Prime(5) " + test_comp2(Prime, 5))
+//println("Prime(4) " + test_comp2(Prime, 4))
println("Strt(1)(2) " + test_comp2(Strt(1), 2))
+def test_comp1a(f: Rec, ns: Int*) = {
+ val (abc_f, arity, _) = compile_rec(f)
+ val tm1 = toTM(abc_f.p)
+ val res = tm1.run(Tape(ns.toList))
+ ("Result: " + res + " length: " + tm1.p.length + " tape: " + arity)
+}
+println("")
+println("S(3) " + test_comp1a(S, 3))
+println("Const(10) " + test_comp1a(Const(10), 0))
+println("Add(6, 3) " + test_comp1a(Add, 6, 3))
+/*
+def test_comp1(f: Rec, ns: Int*) = {
+ val (abc_f, arity, _) = compile_rec(f)
+ val tm = toTM(abc_f.p) :+ TMMopup(arity)
+ val res = tm.run(Tape(ns.toList))
+ ("Result: " + res + " length: " + tm.p.length + " tape: " + arity)
+}
+println("")
+println("S(3) " + test_comp1(S, 3))
+println("Const(10) " + test_comp1(Const(10), 0))
+println("Add(6, 3) " + test_comp1(Add, 6, 3))
+*/
//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))