From efd06d74f1621351c70456478b07a4ace6a9a211 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 31 Mar 2003 08:29:52 +0000 Subject: *** empty log message *** --- test/files/run/Course-2002-01.scala | 12 ++++++------ test/files/run/Course-2002-02.scala | 38 ++++++++++++++++++------------------- test/files/run/Course-2002-03.scala | 28 +++++++++++++-------------- test/files/run/Course-2002-04.scala | 8 ++++---- test/files/run/Course-2002-06.scala | 4 ++-- test/files/run/Course-2002-07.scala | 28 +++++++++++++-------------- test/files/run/Course-2002-08.scala | 14 +++++++------- test/files/run/Course-2002-09.scala | 12 ++++++------ test/files/run/Course-2002-10.scala | 8 ++++---- test/files/run/Course-2002-11.scala | 8 ++++---- test/files/run/Course-2002-13.scala | 8 ++++---- test/files/run/misc.scala | 2 +- test/files/run/queens.scala | 4 ++-- 13 files changed, 87 insertions(+), 87 deletions(-) (limited to 'test/files/run') diff --git a/test/files/run/Course-2002-01.scala b/test/files/run/Course-2002-01.scala index 33b8e2246c..11d29540af 100644 --- a/test/files/run/Course-2002-01.scala +++ b/test/files/run/Course-2002-01.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { //########################################################################## @@ -118,7 +118,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def abs(x: Double) = if (x >= 0) x else -x; def sqrt(x: Double): Double = { @@ -139,7 +139,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def abs(x: Double) = if (x >= 0) x else -x; def sqrt(x:Double):Double = { @@ -161,7 +161,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def abs(x: Double) = if (x >= 0) x else -x; def cbrt(x:Double):Double = { @@ -183,7 +183,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def pascal(c: Int, l: Int): Int = if (c <= 0 || c >= l) 1 else pascal(c - 1, l - 1) + pascal(c, l - 1); @@ -226,7 +226,7 @@ module M4 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-02.scala b/test/files/run/Course-2002-02.scala index a39921b45b..6c78249586 100644 --- a/test/files/run/Course-2002-02.scala +++ b/test/files/run/Course-2002-02.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); def factorial(n: Int): Int = if (n == 0) 1 else n * factorial(n - 1); @@ -14,7 +14,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def cube(x: Int): Double = x * x * x; def sumInts(a: Int, b: Int): Double = @@ -47,7 +47,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; def reciprocal(x: Int): Double = 1.0/x; @@ -74,7 +74,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def sum(f: Int => Double, a: Int, b: Int): Double = if (a > b) 0 else f(a) + sum(f, a + 1, b); @@ -94,7 +94,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def sum(f: Int => Double) = { def sumF(a: Int, b: Int): Double = if (a > b) 0 @@ -117,7 +117,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { def sum(f: Int => Double): (Int, Int) => Double = { (a, b) => if (a > b) 0 else f(a) + sum(f)(a + 1, b) @@ -138,7 +138,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { def sum(f: Int => Double)(a: Int, b: Int): Double = if (a > b) 0 else f(a) + sum(f)(a + 1, b); @@ -158,7 +158,7 @@ module M6 { //############################################################################ -module M7 { +object M7 { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = if (a > b) result @@ -181,7 +181,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { def product(f: Int => Double)(a: Int, step: Int, b: Int): Double = if (a > b) 1 else f(a) * product(f)(a + step, step, b); @@ -197,7 +197,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int) (a: Int, b: Int): t = if (a > b) nullValue @@ -231,7 +231,7 @@ module M9 { //############################################################################ -module MA { +object MA { val tolerance = 0.0001; def abs(x: Double) = if (x < 0) -x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < tolerance; @@ -252,7 +252,7 @@ module MA { //############################################################################ -module MB { +object MB { val tolerance = 0.0001; def abs(x: Double) = if (x < 0) -x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < tolerance; @@ -274,7 +274,7 @@ module MB { //############################################################################ -module MC { +object MC { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = { if (a > b) result @@ -322,7 +322,7 @@ module MC { //############################################################################ -module MD { +object MD { def reduce(op: (Double,Double) => Double, zero:Double) (f: Int => Double)(a: Int,b: Int): Double = { def iter(a: Int, result: Double): Double = { @@ -366,7 +366,7 @@ module MD { //############################################################################ -module ME { +object ME { def reduce(op: (Double,Double) => Double, zero:Double) (f: Int => Double)(a: Int,b: Int): Double = { def iter(a: Int, result: Double): Double = { @@ -410,7 +410,7 @@ module ME { //############################################################################ -module MF { +object MF { def fib(x: Int): Int = if (x <= 1) x else fib(x - 2) + fib(x - 1); @@ -429,7 +429,7 @@ module MF { //############################################################################ -module MG { +object MG { def fib(x: Int) = { def loop(n: Int, prev: Int, fibn: Int): Int = if (n == x) fibn @@ -451,7 +451,7 @@ module MG { //############################################################################ -module MH { +object MH { def power(x: Double, y: Int): Double = if (y <= 0) 1 else if (y % 2 == 0) power(x * x, y / 2) @@ -527,7 +527,7 @@ module MH { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-03.scala b/test/files/run/Course-2002-03.scala index a4efd7ffa6..a2678544e4 100644 --- a/test/files/run/Course-2002-03.scala +++ b/test/files/run/Course-2002-03.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { class Rational(x: Int, y: Int) { def numer = x; def denom = y; @@ -28,7 +28,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { class Rational(x: Int, y: Int) { def numer = x; def denom = y; @@ -55,7 +55,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -92,7 +92,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); def numer = x / gcd(x, y); @@ -114,7 +114,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -147,7 +147,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { trait IntSet { def incl(x: Int): IntSet; def contains(x: Int): Boolean; @@ -179,7 +179,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { trait Boolean { def ifThenElse[a](def t: a)(def e: a): a; @@ -195,15 +195,15 @@ module M6 { def <= (x: Boolean): Boolean = ifThenElse[Boolean](x)(new True()); def >= (x: Boolean): Boolean = ifThenElse[Boolean](new True())(x.!); } - class True() extends Boolean { // !!! class -> module + class True() extends Boolean { // !!! class -> object def ifThenElse[a](def t: a)(def e: a): a = t } - class False() extends Boolean { // !!! class -> module + class False() extends Boolean { // !!! class -> object def ifThenElse[a](def t: a)(def e: a): a = e } } //############################################################################ -module M7 { +object M7 { trait Nat { def isZero(): Boolean; def predecessor: Nat; @@ -215,7 +215,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { trait IntSet { def incl(x: Int): IntSet; @@ -244,7 +244,7 @@ module M8 { } } - class Empty extends IntSet { // !!! class Empty() -> module Empty + class Empty extends IntSet { // !!! class Empty() -> object Empty def contains(x: Int): Boolean = false; def incl(x: Int): IntSet = new NonEmpty(x, new Empty, new Empty); def map(f: Int => Int): IntSet = this; @@ -337,7 +337,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -373,7 +373,7 @@ module M9 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-04.scala b/test/files/run/Course-2002-04.scala index 541dc2ac67..61deb96a11 100644 --- a/test/files/run/Course-2002-04.scala +++ b/test/files/run/Course-2002-04.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { if (xs.isEmpty) @@ -41,7 +41,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def horner (x : Double, coefs : List[Double]) : Double = { if (coefs.isEmpty) @@ -63,7 +63,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def dotproduct (v : List[Double], w : List[Double]) : Double = { if (v.isEmpty) @@ -149,7 +149,7 @@ module M2 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala index d9190d35b5..d044d778d6 100644 --- a/test/files/run/Course-2002-06.scala +++ b/test/files/run/Course-2002-06.scala @@ -145,7 +145,7 @@ class PostScript (filename: String, _width: Double, _height: Double) //############################################################################ -module M0 { +object M0 { /** Define the type of a painter as a function that takes a frame, * draws itself onto it and returns nothing @@ -254,7 +254,7 @@ module M0 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 3d1f21b209..2a45805138 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { trait Expr { def isNumber: boolean; @@ -66,7 +66,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { trait Expr { def eval: int; @@ -93,7 +93,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { trait Expr; case class Number(n: int) extends Expr; @@ -117,7 +117,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { trait Expr { def eval: int = this match { @@ -142,7 +142,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def concat[a](xss: List[List[a]]): List[a] = xss match { case List() => List() @@ -180,7 +180,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match { case Pair(List(), _) => List() @@ -215,7 +215,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match { // !!! case Pair(List(), _), Pair(_, List()) => List() @@ -248,7 +248,7 @@ module M6 { //############################################################################ -module M7 { +object M7 { def heads[a](xss: List[List[a]]): List[a] = xss flatMap { case x :: xs => List(x) @@ -292,7 +292,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { def heads[a](xss: List[List[a]]): List[a] = xss.flatMap { y => y match { @@ -338,7 +338,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { trait Expr { def derive(v: Var): Expr = match { @@ -374,7 +374,7 @@ module M9 { //############################################################################ -module MA { +object MA { def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { case List() => error("no value for " + k) @@ -449,7 +449,7 @@ module MA { //############################################################################ -module Utils { +object Utils { private def power0(x: int, y: int): int = if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); @@ -482,7 +482,7 @@ module Utils { } -module MB { +object MB { import Utils._; @@ -703,7 +703,7 @@ module MB { //############################################################################ -module Test { +object Test { def main(args: Array[String]): unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 9cb2bb8701..dad9426d7f 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -5,7 +5,7 @@ import List._; -module M0 { +object M0 { var x: String = "abc"; var count = 111; @@ -23,7 +23,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { class BankAccount() { private var balance = 0; @@ -87,7 +87,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def while(def condition: Boolean)(def command: Unit): Unit = if (condition) { @@ -113,7 +113,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def power (x: Double, exp: Int): Double = { var r = 1.0; @@ -133,7 +133,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def test = { for (val i <- range(1, 4)) do { System.out.print(i + " ") }; @@ -145,7 +145,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { type Action = () => Unit; @@ -579,7 +579,7 @@ class Main() extends CircuitSimulator() { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 2e012fdf35..4238402263 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -12,7 +12,7 @@ trait Constraint { def dropValue: Unit } -module NoConstraint extends Constraint { +object NoConstraint extends Constraint { def newValue: Unit = error("NoConstraint.newValue"); def dropValue: Unit = error("NoConstraint.dropValue"); } @@ -168,7 +168,7 @@ class Quantity() { //############################################################################ -module M0 { +object M0 { def CFconverter(c: Quantity, f: Quantity) = { val u = new Quantity(); @@ -209,7 +209,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def constant(x: double): Quantity = { val q = new Quantity(); @@ -250,7 +250,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { val a = new Quantity(); val b = new Quantity(); @@ -298,7 +298,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def test = { val a = new Quantity(); @@ -324,7 +324,7 @@ module M3 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-10.scala b/test/files/run/Course-2002-10.scala index aabe99ba53..9a292937ca 100644 --- a/test/files/run/Course-2002-10.scala +++ b/test/files/run/Course-2002-10.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def addStream (s1: Stream[int], s2: Stream[int]): Stream[int] = Stream.cons(s1.head + s2.head, addStream(s1.tail, s2.tail)); @@ -20,7 +20,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def scale(x: double, s: Stream[double]): Stream[double] = s map (e: double => e*x); @@ -92,7 +92,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { class IntIterator(start: int) extends Iterator[int] { var current: int = start; @@ -120,7 +120,7 @@ module M2 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-11.scala b/test/files/run/Course-2002-11.scala index 5a257234c4..c7cae8bb53 100644 --- a/test/files/run/Course-2002-11.scala +++ b/test/files/run/Course-2002-11.scala @@ -5,7 +5,7 @@ import List._; -module Lisp { +object Lisp { trait Data { def elemsToString(): String = toString(); @@ -17,7 +17,7 @@ module Lisp { case _ => " " + cdr.elemsToString(); }) } - case class NIL() extends Data { // !!! use case module + case class NIL() extends Data { // !!! use case object override def toString() = "()"; } case class SYM(name: String) extends Data { @@ -237,7 +237,7 @@ class LispTokenizer(s: String) extends Iterator[String] { //############################################################################ -module M0 { +object M0 { def test = { import Lisp._; @@ -288,7 +288,7 @@ module M0 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index 0fdb715991..ebdde8bf86 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -82,7 +82,7 @@ class Interpreter { } -module Terms { +object Terms { val debug = false; @@ -159,7 +159,7 @@ module Terms { import Terms._; -module Programs { +object Programs { case class Clause(lhs: Term, rhs: List[Term]) { def tyvars = @@ -262,7 +262,7 @@ class Parser(s: String) { def all: List[Clause] = if (token equals "") List() else line :: all; } -module Prolog { +object Prolog { def processor: String => Unit = { var program: List[Clause] = List(); @@ -304,7 +304,7 @@ module Prolog { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { Prolog.process( "sujet(jean).\n" + diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala index dd82d097cd..1468193ab6 100644 --- a/test/files/run/misc.scala +++ b/test/files/run/misc.scala @@ -1,6 +1,6 @@ // $Id$ -module Test { +object Test { def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n; diff --git a/test/files/run/queens.scala b/test/files/run/queens.scala index 2a705c4892..4daa702e29 100644 --- a/test/files/run/queens.scala +++ b/test/files/run/queens.scala @@ -1,6 +1,6 @@ // $Id$ -module M0 { +object M0 { type Placement = List[Int]; def range(lo: Int, hi: Int): List[Int] = @@ -41,7 +41,7 @@ module M0 { } } -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () -- cgit v1.2.3