Skip to content

Instantly share code, notes, and snippets.

@krrrr38
Created February 13, 2012 01:47
Show Gist options
  • Save krrrr38/1812579 to your computer and use it in GitHub Desktop.
Save krrrr38/1812579 to your computer and use it in GitHub Desktop.
なんか勘違いしてる?解決済
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