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 /test/pending | |
parent | c243435f113615b2f7407fbd683c93ec16c73749 (diff) | |
download | scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.gz scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.bz2 scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.zip |
deprecate Pair and Triple
Diffstat (limited to 'test/pending')
-rw-r--r-- | test/pending/run/reify_callccinterpreter.scala | 12 | ||||
-rw-r--r-- | test/pending/run/reify_simpleinterpreter.scala | 10 | ||||
-rw-r--r-- | test/pending/shootout/fasta.scala | 64 | ||||
-rw-r--r-- | test/pending/shootout/revcomp.scala-2.scala | 18 | ||||
-rw-r--r-- | test/pending/shootout/revcomp.scala-3.scala | 40 |
5 files changed, 72 insertions, 72 deletions
diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala index d9f7736769..82c70da28f 100644 --- a/test/pending/run/reify_callccinterpreter.scala +++ b/test/pending/run/reify_callccinterpreter.scala @@ -43,15 +43,15 @@ object Test extends App { override def toString() = "<function>" } - type Environment = List[Pair[Name, Value]]; + type Environment = List[Tuple2[Name, Value]]; def lookup(x: Name, e: Environment): M[Value] = e match { case List() => unitM(Wrong) - case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) + case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) } - def add(a: Value, b: Value): M[Value] = Pair(a, b) match { - case Pair(Num(m), Num(n)) => unitM(Num(m + n)) + def add(a: Value, b: Value): M[Value] = (a, b) match { + case (Num(m), Num(n)) => unitM(Num(m + n)) case _ => unitM(Wrong) } @@ -67,12 +67,12 @@ object Test extends App { b <- interp(r, e); c <- add(a, b)) yield c - case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e))) + case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e))) case App(f, t) => for (a <- interp(f, e); b <- interp(t, e); c <- apply(a, b)) yield c - case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e)) + case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e)) } def test(t: Term): String = showM(interp(t, List())) diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala index 6cf87ea7c5..1f6d6c8da7 100644 --- a/test/pending/run/reify_simpleinterpreter.scala +++ b/test/pending/run/reify_simpleinterpreter.scala @@ -32,15 +32,15 @@ object Test extends App { override def toString() = "<function>" } - type Environment = List[Pair[Name, Value]] + type Environment = List[Tuple2[Name, Value]] def lookup(x: Name, e: Environment): M[Value] = e match { case List() => unitM(Wrong) - case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) + case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) } - def add(a: Value, b: Value): M[Value] = Pair(a, b) match { - case Pair(Num(m), Num(n)) => unitM(Num(m + n)) + def add(a: Value, b: Value): M[Value] = (a, b) match { + case (Num(m), Num(n)) => unitM(Num(m + n)) case _ => unitM(Wrong) } @@ -56,7 +56,7 @@ object Test extends App { b <- interp(r, e); c <- add(a, b)) yield c - case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e))) + case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e))) case App(f, t) => for (a <- interp(f, e); b <- interp(t, e); c <- apply(a, b)) diff --git a/test/pending/shootout/fasta.scala b/test/pending/shootout/fasta.scala index 8b711083a5..ae99ba5936 100644 --- a/test/pending/shootout/fasta.scala +++ b/test/pending/shootout/fasta.scala @@ -5,7 +5,7 @@ import java.io._ -object fasta { +object fasta { def main(args: Array[String]) = { val ALU = @@ -18,31 +18,31 @@ object fasta { "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" val _IUB = Array( - Pair('a', 0.27), - Pair('c', 0.12), - Pair('g', 0.12), - Pair('t', 0.27), - - Pair('B', 0.02), - Pair('D', 0.02), - Pair('H', 0.02), - Pair('K', 0.02), - Pair('M', 0.02), - Pair('N', 0.02), - Pair('R', 0.02), - Pair('S', 0.02), - Pair('V', 0.02), - Pair('W', 0.02), - Pair('Y', 0.02) + ('a', 0.27), + ('c', 0.12), + ('g', 0.12), + ('t', 0.27), + + ('B', 0.02), + ('D', 0.02), + ('H', 0.02), + ('K', 0.02), + ('M', 0.02), + ('N', 0.02), + ('R', 0.02), + ('S', 0.02), + ('V', 0.02), + ('W', 0.02), + ('Y', 0.02) ) val IUB = makeCumulative(_IUB) val _HomoSapiens = Array( - Pair('a', 0.3029549426680), - Pair('c', 0.1979883004921), - Pair('g', 0.1975473066391), - Pair('t', 0.3015094502008) + ('a', 0.3029549426680), + ('c', 0.1979883004921), + ('g', 0.1975473066391), + ('t', 0.3015094502008) ) val HomoSapiens = makeCumulative(_HomoSapiens) @@ -61,15 +61,15 @@ object fasta { s.writeRandomSequence(HomoSapiens,n*5) s.close - } + } - def makeCumulative(a: Array[Pair[Char,Double]]) = { + def makeCumulative(a: Array[Tuple2[Char,Double]]) = { var cp = 0.0 a map (frequency => - frequency match { - case Pair(code,percent) => - cp = cp + percent; new Frequency(code.toByte,cp) - } + frequency match { + case (code,percent) => + cp = cp + percent; new Frequency(code.toByte,cp) + } ) } @@ -79,7 +79,7 @@ object fasta { // We could use instances of Pair or Tuple2 but specific labels // make the code more readable than index numbers -class Frequency(_code: Byte, _percent: Double){ +class Frequency(_code: Byte, _percent: Double){ var code = _code; var percent = _percent; } @@ -101,13 +101,13 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) { val m = if (n < LineLength) n else LineLength var i = 0 - while (i < m){ + while (i < m){ if (k == kn) k = 0 val b = alu(k) if (count < buf.length){ buf(count) = b; count = count + 1 } else { write(b) } // flush buffer k = k+1 - i = i+1 + i = i+1 } write(nl) @@ -122,11 +122,11 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) { val m = if (n < LineLength) n else LineLength var i = 0 - while (i < m){ + while (i < m){ val b = selectRandom(distribution) if (count < buf.length){ buf(count) = b; count = count + 1 } else { write(b) } // flush buffer - i = i+1 + i = i+1 } if (count < buf.length){ buf(count) = nl; count = count + 1 } diff --git a/test/pending/shootout/revcomp.scala-2.scala b/test/pending/shootout/revcomp.scala-2.scala index 92260ad021..03fb25af1b 100644 --- a/test/pending/shootout/revcomp.scala-2.scala +++ b/test/pending/shootout/revcomp.scala-2.scala @@ -6,7 +6,7 @@ import java.io._ import scala.collection.mutable.Stack -object revcomp { +object revcomp { val IUB = IUBCodeComplements @@ -16,7 +16,7 @@ object revcomp { val a: Array[Byte] = new Array( 'z'.toByte ) for (indexValue <- code zip comp) - indexValue match { case Pair(i,v) => a(i) = v } + indexValue match { case (i,v) => a(i) = v } a } @@ -49,18 +49,18 @@ object revcomp { if (desc.length > 0) complementReverseWrite(desc, lines, w) w.close - } + } - def complementReverseWrite(desc: String, lines: LineStack, + def complementReverseWrite(desc: String, lines: LineStack, w: BufferedOutputStream) = { def inplaceComplementReverse(b: Array[Byte]) = { - var i = 0 + var i = 0 var j = b.length - 1 while (i < j){ - val swap = b(i) - b(i) = IUB( b(j) ) + val swap = b(i) + b(i) = IUB( b(j) ) b(j) = IUB( swap ) i = i + 1 j = j - 1 @@ -79,11 +79,11 @@ object revcomp { while (!lines.isEmpty) { val line = lines.pop inplaceComplementReverse(line) - + if (isSplitLine){ if (isFirstLine){ w.write(line); isFirstLine = false } else { w.write(line,0,n-k); w.write(nl); w.write(line,n-k,k) } - } + } else { w.write(line); w.write(nl) } } if (isSplitLine && !isFirstLine) w.write(nl) diff --git a/test/pending/shootout/revcomp.scala-3.scala b/test/pending/shootout/revcomp.scala-3.scala index ae12f0499b..39a0409127 100644 --- a/test/pending/shootout/revcomp.scala-3.scala +++ b/test/pending/shootout/revcomp.scala-3.scala @@ -6,7 +6,7 @@ import java.io._ import scala.collection.mutable.Stack -object revcomp { +object revcomp { def main(args: Array[String]) = { val out = new FastaOutputStream(System.out) val in = new FastaInputStream(System.in) @@ -17,12 +17,12 @@ object revcomp { in.close out.close - } + } } trait FastaByteStream { - val nl = '\n'.toByte + val nl = '\n'.toByte type Line = Array[Byte] type LineStack = Stack[Line] @@ -31,13 +31,13 @@ trait FastaByteStream { // extend the Java BufferedInputStream class -final class FastaInputStream(in: InputStream) +final class FastaInputStream(in: InputStream) extends BufferedInputStream(in) with FastaByteStream { val gt = '>'.toByte val sc = ';'.toByte - def readSequenceStack(): Pair[Line,LineStack] = { + def readSequenceStack(): Tuple2[Line,LineStack] = { var header: Line = null val lines: LineStack = new Stack @@ -49,14 +49,14 @@ final class FastaInputStream(in: InputStream) header = line } else { pos = pos - line.length - 1 // reposition to start of line - return Pair(header,lines) + return (header,lines) } } else { if (c != sc) lines push line // ';' } line = readLine() } - return Pair(header,lines) + return (header,lines) } def readLine() = { @@ -65,7 +65,7 @@ final class FastaInputStream(in: InputStream) else { mark(128) // mark the start of the line if (count == 0) read() // fill buffer - + var i = markpos while (i < count && buf(i) != nl) i = i + 1 @@ -74,11 +74,11 @@ final class FastaInputStream(in: InputStream) while (i < count && buf(i) != nl) i = i + 1 } - if (i < count){ + if (i < count){ bytes = new Array(i - markpos) System.arraycopy(buf, markpos, bytes, 0, i - markpos); pos = i+1 - } + } } bytes } @@ -87,7 +87,7 @@ final class FastaInputStream(in: InputStream) // extend the Java BufferedOutputStream class -final class FastaOutputStream(in: OutputStream) +final class FastaOutputStream(in: OutputStream) extends BufferedOutputStream(in) with FastaByteStream { private val IUB = IUBCodeComplements @@ -98,19 +98,19 @@ final class FastaOutputStream(in: OutputStream) val iub: Array[Byte] = new Array( 'z'.toByte ) for (indexValue <- code zip comp) - indexValue match { case Pair(i,v) => iub(i) = v } + indexValue match { case (i,v) => iub(i) = v } iub } - def writeReverseComplement(sequence: Pair[Line,LineStack]) = { + def writeReverseComplement(sequence: Tuple2[Line,LineStack]) = { def inplaceComplementReverse(b: Array[Byte]) = { - var i = 0 + var i = 0 var j = b.length - 1 while (i < j){ - val swap = b(i) - b(i) = IUB( b(j) ) + val swap = b(i) + b(i) = IUB( b(j) ) b(j) = IUB( swap ) i = i + 1 j = j - 1 @@ -119,7 +119,7 @@ final class FastaOutputStream(in: OutputStream) } sequence match { - case Pair(header,lines) => { + case (header,lines) => { write(header); write(nl) @@ -131,11 +131,11 @@ final class FastaOutputStream(in: OutputStream) while (!lines.isEmpty) { val line = lines.pop inplaceComplementReverse(line) - + if (isSplitLine){ - if (isFirstLine){ write(line); isFirstLine = false } + if (isFirstLine){ write(line); isFirstLine = false } else { write(line,0,LineLength-k); write(nl); write(line,LineLength-k,k) } - } + } else { write(line); write(nl) } } |