diff options
author | paltherr <paltherr@epfl.ch> | 2003-07-18 07:54:07 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-07-18 07:54:07 +0000 |
commit | 9500f0c78cc43d89e4c23e881449e62b681ae578 (patch) | |
tree | ea2c919ee789401e607ffd925da6b60fa1b2e17a /test/files/pos | |
parent | 9efa9931068a56685f9f807f5dbf3d32b193dcdf (diff) | |
download | scala-9500f0c78cc43d89e4c23e881449e62b681ae578.tar.gz scala-9500f0c78cc43d89e4c23e881449e62b681ae578.tar.bz2 scala-9500f0c78cc43d89e4c23e881449e62b681ae578.zip |
- Removed duplicates
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/IntSet.scala | 36 | ||||
-rw-r--r-- | test/files/pos/Rational.scala | 25 |
2 files changed, 0 insertions, 61 deletions
diff --git a/test/files/pos/IntSet.scala b/test/files/pos/IntSet.scala deleted file mode 100644 index 25d7070c94..0000000000 --- a/test/files/pos/IntSet.scala +++ /dev/null @@ -1,36 +0,0 @@ -trait IntSet { - def incl(x: Int): IntSet; - def contains(x: Int): Boolean; - def foreach(f: Int => Unit): Unit; - def union(that: IntSet): IntSet; -} -object Empty extends IntSet { - def contains(x: Int): Boolean = false; - def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty); - def foreach(f: Int => Unit): Unit = (); - def union(that: IntSet): IntSet = that; -} -class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { - def contains(x: Int): Boolean = - if (x < elem) left contains x - else if (x > elem) right contains x - else true; - def incl(x: Int): IntSet = - if (x < elem) new NonEmpty(elem, left incl x, right) - else if (x > elem) new NonEmpty(elem, left, right incl x) - else this; - def foreach(f: Int => Unit): Unit = { - left foreach f; - f(elem); - right foreach f; - } - def union(that: IntSet): IntSet = (left union (right union that)) incl elem; -} -object test { - def main = { - val x = Empty incl 1 incl 2; - val y = Empty incl 2 incl 3; - x foreach java.lang.System.out.println; - y foreach java.lang.System.out.println; - } -} diff --git a/test/files/pos/Rational.scala b/test/files/pos/Rational.scala deleted file mode 100644 index 14236975d4..0000000000 --- a/test/files/pos/Rational.scala +++ /dev/null @@ -1,25 +0,0 @@ -class Rational(x: Int, y: Int) { - private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); - private def g = gcd(x, y); - def numer = x / g; - def denom = y / g; - def add(r: Rational) = - new Rational( - numer * r.denom + r.numer * denom, - denom * r.denom); - def sub(r: Rational) = - new Rational( - numer * r.denom - r.numer * denom, - denom * r.denom); - def mul(r: Rational) = - new Rational( - numer * r.numer, - denom * r.denom); - def equal(r: Rational) = - new Rational( - numer * r.denom, - denom * r.numer); - - def asString: String = numer + "/" + denom; - override def toString(): String = numer + "/" + denom -} |