val dna1 = "ATATCCG"
val dna2 = "TCCGA"
val dna3 = "ATGTACTG"
val arr = Array.ofDim[(Int, (Int, Int, Int))](dna1.length + 1, dna2.length + 1, dna3.length + 1)
for (i1 <- 0 to dna1.length)
for (i2 <- 0 to dna2.length)
for (i3 <- 0 to dna3.length)
arr(i1)(i2)(i3) = {
def mkPair(i1: Int, i2: Int, i3: Int, diff: Int = 0) = {
(arr(i1)(i2)(i3)._1 + diff, (i1, i2, i3))
}
if (i1 + i2 + i3 == 0) (0, null)
else if (i1 * i2 * i3 == 0) (0, (0 max (i1 - 1), 0 max (i2 - 1), 0 max (i3 - 1)))
else List(
mkPair(i1 - 1, i2 - 1, i3 - 1, if (dna1(i1 - 1) == dna2(i2 - 1) && dna1(i1 - 1) == dna3(i3 - 1)) 1 else 0),
mkPair(i1, i2 - 1, i3 - 1),
mkPair(i1 - 1, i2, i3 - 1),
mkPair(i1 - 1, i2 - 1, i3),
mkPair(i1 - 1, i2, i3),
mkPair(i1, i2 - 1, i3),
mkPair(i1, i2, i3 - 1)
).maxBy(_._1)
}
我收到一些错误我还没有得到分号,它不应该去哪里?...
error: value maxBy is not a member of List[(Int, (Int, Int, Int))]
possible cause: maybe a semicolon is missing before `value maxBy'?
).maxBy(_._1)
^
解决此问题的最佳方法是什么?
答案 0 :(得分:4)
使用scalac 2.10.0为我编译好。 Scala 2.9.0中添加了maxBy
。确保使用scalac 2.9.0+编译代码。