equal
deleted
inserted
replaced
63 // Turing machines |
63 // Turing machines |
64 case class TM(p: Prog) { |
64 case class TM(p: Prog) { |
65 |
65 |
66 // composition |
66 // composition |
67 def ++ (that: TM) = TM(this.p ::: that.p) |
67 def ++ (that: TM) = TM(this.p ::: that.p) |
68 def :+ (that: TM) = this.adjust ++ that.shift(this.p.length / 2 + 1) |
68 def :+ (that: TM) = this.adjust ++ that.shift(this.p.length / 2) |
69 |
69 |
70 def shift(n: Int) = |
70 def shift(n: Int) = |
71 TM(p.map{case (a, s) => (a, if (s == 0) 0 else s + n)}) |
71 TM(p.map{case (a, s) => (a, if (s == 0) 0 else s + n)}) |
72 def adjust(n: Int) : TM = |
72 def adjust(n: Int) : TM = |
73 TM(p.map{case (a, s) => (a, if (s == 0) n else s)}) |
73 TM(p.map{case (a, s) => (a, if (s == 0) n else s)}) |