summaryrefslogtreecommitdiff
path: root/test/files/run/Course-2002-10.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-05-20 15:43:03 +0000
committermichelou <michelou@epfl.ch>2008-05-20 15:43:03 +0000
commita81ac63831dfbf55c39952ffe9ec94b560308c15 (patch)
treefcc0b5318ced3daa02406fecc77648ff3f81aa86 /test/files/run/Course-2002-10.scala
parent17ce6cb275d18e9af4e13d1c552a5ff97fc3d5e8 (diff)
downloadscala-a81ac63831dfbf55c39952ffe9ec94b560308c15.tar.gz
scala-a81ac63831dfbf55c39952ffe9ec94b560308c15.tar.bz2
scala-a81ac63831dfbf55c39952ffe9ec94b560308c15.zip
int -> Int, etc..
Diffstat (limited to 'test/files/run/Course-2002-10.scala')
-rw-r--r--test/files/run/Course-2002-10.scala40
1 files changed, 20 insertions, 20 deletions
diff --git a/test/files/run/Course-2002-10.scala b/test/files/run/Course-2002-10.scala
index a150fb39c3..96df090c05 100644
--- a/test/files/run/Course-2002-10.scala
+++ b/test/files/run/Course-2002-10.scala
@@ -7,10 +7,10 @@ import Math.{Pi, log}
object M0 {
- def addStream (s1: Stream[int], s2: Stream[int]): Stream[int] =
+ def addStream (s1: Stream[Int], s2: Stream[Int]): Stream[Int] =
Stream.cons(s1.head + s2.head, addStream(s1.tail, s2.tail));
- val fib: Stream[int] =
+ val fib: Stream[Int] =
Stream.cons(0, Stream.cons(1, addStream(this.fib, this.fib.tail)));
def test = {
@@ -24,45 +24,45 @@ object M0 {
object M1 {
- def scale(x: double, s: Stream[double]): Stream[double] =
- s map { e: double => e*x }
+ def scale(x: Double, s: Stream[Double]): Stream[Double] =
+ s map { e: Double => e*x }
- def partialSums(s: Stream[double]): Stream[double] =
+ def partialSums(s: Stream[Double]): Stream[Double] =
Stream.cons(s.head, partialSums(s.tail) map (x => x + s.head));
- def euler(s: Stream[double]): Stream[double] = {
+ def euler(s: Stream[Double]): Stream[Double] = {
val nm1 = s apply 0;
val n = s apply 1;
val np1 = s apply 2;
Stream.cons(np1 - ((np1 - n)*(np1 - n) / (nm1 - 2*n + np1)),euler(s.tail))
};
- def better(s: Stream[double], transform: Stream[double] => Stream[double])
- : Stream[Stream[double]] =
+ def better(s: Stream[Double], transform: Stream[Double] => Stream[Double])
+ : Stream[Stream[Double]] =
Stream.cons(s, better(transform(s), transform));
- def veryGood(s: Stream[double], transform: Stream[double] => Stream[double])
- : Stream[double] =
+ def veryGood(s: Stream[Double], transform: Stream[Double] => Stream[Double])
+ : Stream[Double] =
better(s, transform) map (x => x.head);
- def lnSummands(n: double): Stream[double] =
- Stream.cons(1.0 / n, lnSummands(n + 1.0) map { x: double => -x })
+ def lnSummands(n: Double): Stream[Double] =
+ Stream.cons(1.0 / n, lnSummands(n + 1.0) map { x: Double => -x })
var ln0 = partialSums(lnSummands(1.0));
var ln1 = euler(ln0);
var ln2 = veryGood(ln0, euler);
- def piSummands(n: double): Stream[double] =
- Stream.cons(1.0 / n, piSummands(n + 2.0) map { x: double => -x })
+ def piSummands(n: Double): Stream[Double] =
+ Stream.cons(1.0 / n, piSummands(n + 2.0) map { x: Double => -x })
var pi0 = scale(4.0, partialSums(piSummands(1.0)));
var pi1 = euler(pi0);
var pi2 = veryGood(pi0, euler);
- def pad(s: String, n: int): String =
+ def pad(s: String, n: Int): String =
if (n <= 0) s.substring(0, s.length() + n)
else pad(s + " ", n - 1);
- def str(d: double) = { val s = d.toString(); pad(s, 18 - s.length()) };
+ def str(d: Double) = { val s = d.toString(); pad(s, 18 - s.length()) };
def test = {
var i = 0;
@@ -98,14 +98,14 @@ object M1 {
object M2 {
- class IntIterator(start: int) extends Iterator[int] {
- var current: int = start;
+ class IntIterator(start: Int) extends Iterator[Int] {
+ var current: Int = start;
def hasNext = true;
def next = { current = current + 1; current - 1 };
}
- class PrimeIterator() extends Iterator[int] {
- var current: Iterator[int] = new IntIterator(2);
+ class PrimeIterator() extends Iterator[Int] {
+ var current: Iterator[Int] = new IntIterator(2);
def hasNext = true;
def next = {
val p = current.next;