Created
February 13, 2012 01:47
-
-
Save krrrr38/1812579 to your computer and use it in GitHub Desktop.
なんか勘違いしてる?解決済
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def permutation(l: List[Int]): Iterator[List[Int]] = { | |
if (l.isEmpty) | |
Iterator(Nil) | |
else | |
// for (i <- 0 until l.length; | |
for (i <- Iterator.range(0, l.length); | |
next <- permutation(l.slice(0, i) ::: l.slice(i+1, l.length))) | |
yield l(i) :: next | |
} | |
// <console>:12: error: type mismatch; | |
// found : scala.collection.immutable.IndexedSeq[List[Int]] | |
// required: Iterator[List[Int]] | |
// for (i <- 0 until l.length; | |
// ^ | |
// 解決 | |
// elseの方どこにもIterator無くてgeneratorになってないやん... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment