diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-11-13 15:33:33 +0100 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-11-20 16:06:30 +0100 |
commit | b004c3ddb38f8e690a0895a51ad0c83ff57a01e7 (patch) | |
tree | 0c31f83d2e039db4c2ead7a3280aaabc78671333 /docs/examples/monads/directInterpreter.scala | |
parent | c243435f113615b2f7407fbd683c93ec16c73749 (diff) | |
download | scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.gz scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.bz2 scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.zip |
deprecate Pair and Triple
Diffstat (limited to 'docs/examples/monads/directInterpreter.scala')
-rw-r--r-- | docs/examples/monads/directInterpreter.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/examples/monads/directInterpreter.scala b/docs/examples/monads/directInterpreter.scala index 06fffba8e2..d8ca8ccfa7 100644 --- a/docs/examples/monads/directInterpreter.scala +++ b/docs/examples/monads/directInterpreter.scala @@ -20,15 +20,15 @@ object directInterpreter { case Fun(f) => "<function>" } - type Environment = List[Pair[Name, Value]]; + type Environment = List[Tuple2[Name, Value]]; def lookup(x: Name, e: Environment): Value = e match { case List() => Wrong - case Pair(y, b) :: e1 => if (x == y) b else lookup(x, e1) + case (y, b) :: e1 => if (x == y) b else lookup(x, e1) } - def add(a: Value, b: Value): Value = Pair(a, b) match { - case Pair(Num(m), Num(n)) => Num(m + n) + def add(a: Value, b: Value): Value = (a, b) match { + case (Num(m), Num(n)) => Num(m + n) case _ => Wrong } @@ -41,15 +41,15 @@ object directInterpreter { case Var(x) => lookup(x, e) case Con(n) => Num(n) case Add(l, r) => add(interp(l, e), interp(r, e)) - case Lam(x, t) => Fun(a => interp(t, Pair(x, a) :: e)) + case Lam(x, t) => Fun(a => interp(t, (x, a) :: e)) case App(f, t) => apply(interp(f, e), interp(t, e)) } - def test(t: Term): String = + def test(t: Term): String = showval(interp(t, List())); val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))); - def main(args: Array[String]) = + def main(args: Array[String]) = System.out.println(test(term0)); } |