diff options
author | Martin Odersky <odersky@gmail.com> | 2004-04-08 15:13:56 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-04-08 15:13:56 +0000 |
commit | 99ec3e8abcca88be3362e396d25f3bf2c22d6528 (patch) | |
tree | 5fd467630508d0d4c75fd97d04f29671225bf681 /test | |
parent | 64d2fb73cd89afbb1df3976dda189ad0cc8a8d0a (diff) | |
download | scala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.tar.gz scala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.tar.bz2 scala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.zip |
*** empty log message ***
Diffstat (limited to 'test')
-rwxr-xr-x | test/files/pos/viewtest2.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/pos/viewtest2.scala b/test/files/pos/viewtest2.scala index aa8d33ed6c..880ee2a57a 100755 --- a/test/files/pos/viewtest2.scala +++ b/test/files/pos/viewtest2.scala @@ -1,6 +1,29 @@ package test; +/** A trait for totally ordered data. + */ +trait Ordered[+a] { + + /** Result of comparing `this' with operand `that'. + * returns `x' where + * x < 0 iff this < that + * x == 0 iff this == that + * x > 0 iff this > that + */ + def compareTo [b >: a <% Ordered[b]](that: b): int; + + def < [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) < 0; + + def > [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) > 0; + + def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0; + + def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0; +} + + object O { + def view (x: String): Ordered[String] = new Ordered[String] { def compareTo [b >: String <% Ordered[b]](y: b): int = y match { case y1: String => x compareTo y1; @@ -13,6 +36,7 @@ object O { case _ => -(y compareTo x) } } + def view[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] { def compareTo [b >: List[a] <% Ordered[b]](y: b): int = y match { |