2 import turing._ |
2 import turing._ |
3 import abacus._ |
3 import abacus._ |
4 import recs._ |
4 import recs._ |
5 import comp1._ |
5 import comp1._ |
6 import comp2._ |
6 import comp2._ |
|
7 |
|
8 print(compile_rec(S)._1.print) |
7 |
9 |
8 // Turing machine examples |
10 // Turing machine examples |
9 val TMCopy = TM((WBk, 5), (R, 2), (R, 3), (R, 2), (WOc, 3), |
11 val TMCopy = TM((WBk, 5), (R, 2), (R, 3), (R, 2), (WOc, 3), |
10 (L, 4), (L, 4), (L, 5), (R, 11), (R, 6), |
12 (L, 4), (L, 4), (L, 5), (R, 11), (R, 6), |
11 (R, 7), (WBk, 6), (R, 7), (R, 8), (WOc, 9), |
13 (R, 7), (WBk, 6), (R, 7), (R, 8), (WOc, 9), |
92 val abc_map = (0 until ns.length).zip(ns).toMap[Int, Int] |
94 val abc_map = (0 until ns.length).zip(ns).toMap[Int, Int] |
93 val start = System.nanoTime() |
95 val start = System.nanoTime() |
94 val res = (abc_f.run(abc_map))(arity) |
96 val res = (abc_f.run(abc_map))(arity) |
95 val end = System.nanoTime() |
97 val end = System.nanoTime() |
96 val time = (end - start)/1.0e9 |
98 val time = (end - start)/1.0e9 |
97 ("Result: " + res + " length: " + abc_f.p.length + " time: " + "%.5f".format(time)) |
99 ("Result: " + res + " length: " + abc_f.p.length + " time: " + "%.5f".format(time) + "\n Prog:" + abc_f) |
98 } |
100 } |
99 |
101 |
100 println("S(3) " + test_comp2(S, 3)) |
102 println("S(3) " + test_comp2(S, 3)) |
101 println("Const(1) " + test_comp2(Const(1), 0)) |
103 println("Const(1) " + test_comp2(Const(1), 0)) |
102 println("Const(10) " + test_comp2(Const(10), 0)) |
104 println("Const(10) " + test_comp2(Const(10), 0)) |