scala/ex.scala
changeset 270 ccec33db31d4
parent 269 fa40fd8abb54
child 271 4457185b22ef
--- a/scala/ex.scala	Wed Jun 26 14:35:43 2013 +0100
+++ b/scala/ex.scala	Wed Jun 26 14:42:42 2013 +0100
@@ -2,18 +2,8 @@
 import turing._
 import abacus._
 import recs._
-import comp1._
-import comp2._
-
-val Lg = {
-  val lgR = Le o (Power o (Id(3, 1), Id(3, 2)), Id(3, 0))
-  val conR1 = Conj o (Less o (Const(1) o (Id(2, 0), Id(2, 0))), 
-                     Less o (Const(1) o (Id(2, 0), Id(2, 1))))
-  val conR2 = Not o (conR1)
-  Add o (recs.Mult o (conR1, Maxr(lgR) o (Id(2, 0), Id(2, 1), Id(2, 0))), 
-         recs.Mult o (conR2, Const(0) o (Id(2, 0)))) 
-}
-
+//import comp1._
+//import comp2._
 
 
 // Turing machine examples
@@ -24,12 +14,14 @@
                 (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("TMCopyMop: " + ((TMCopy :+ TMMopup(0))))
 println("TMCopyMop: " + ((TMCopy :+ TMMopup(1)).run(Tape(3))))
+*/
 
 // Abacus machine examples
 def Copy(in: Int, out: Int, jump: Int) = 
@@ -52,13 +44,14 @@
 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
 println("Compiled Copy 3:     " + toTM(Copy(0, 1, Int.MaxValue).p).run(Tape(3,0,0)))
 println("Compiled Plus 3 + 4: " + toTM(Plus(0, 1, 2, Int.MaxValue).p).run(Tape(3,4,0,0)))
 println("Compiled Mult 3 * 5: " + toTM(Mult(0, 1, 2, 3, Int.MaxValue).p).run(Tape(3,5,0,0)))
 println("Compiled Expo 3 ^ 4: " + toTM(Expo(0, 1, 2, 3, 4, 10000).p).run(Tape(3,4,0,0,0)))
-
+*/
+ 
 // Recursive function examples 
 println("Const 8:   " + Const(8).eval(67))
 println("Add 3 4:   " + Add.eval(3, 4))
@@ -105,7 +98,7 @@
 
 println("Sigma1 Add 2 3 -> 12: " + Sigma1(Add).eval(2, 3))
 println("Accum1 Add 2 3 -> 60:  " + Accum1(Add).eval(2,3))
-println("Accum1 Mult 2 3 -> 0:  " + Accum1(Mult).eval(2,3))
+println("Accum1 Mult 2 3 -> 0:  " + Accum1(recs.Mult).eval(2,3))
 println("Accum1 (Id(2, 1)) 2 3 -> 27:  " + Accum1(Id(2, 1)).eval(2,3))
 println("Accum2 (Id(3, 1)) 2 3 3 -> 27:  " + Accum2(Id(3, 1)).eval(2,3,3))
 println("Accum3 (Id(4, 1)) 2 3 3 3 -> 27:  " + Accum3(Id(4, 1)).eval(2,3,3,3))
@@ -128,8 +121,9 @@
 println("Penc 1 2 -> 7: " + Penc.eval(1, 2))
 println("Pdec1 7 -> 1:  " + Pdec1.eval(7))
 println("Pdec2 7 -> 2:  " + Pdec2.eval(7))
-println("Enclen 0 .. 10: " + (0 until 10).map(EncLen.eval(_)))
+println("Enclen 0 .. 10: " + (0 until 10).map(Enclen.eval(_)))
 
+/*
 // compilation of rec to abacus tests
 def test_comp2(f: Rec, ns: Int*) = {
   val (abc_f, arity, _) = compile_rec(f)
@@ -168,3 +162,4 @@
 println("Mult(4, 5)    " + test_comp1(recs.Mult, 4, 5))
 println("Fact(4)       " + test_comp1(Fact, 4))
 
+*/