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
/** | |
* A tiny class that extends a list with four combinatorial operations: | |
* ''combinations'', ''subsets'', ''permutations'', ''variations''. | |
* | |
* You can find all the ideas behind this code at blog-post: | |
* | |
* http://vkostyukov.ru/posts/combinatorial-algorithms-in-scala/ | |
* | |
* How to use this class. | |
* |
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
import scala.reflect.ClassTag | |
import scala.collection.mutable.WrappedArray | |
import scala.collection.mutable.ArrayLike | |
def ASeq[T](elt: T*)(implicit ct: ClassTag[T]): IndexedSeq[T] = { | |
val a = elt.toArray.clone | |
a.deep.asInstanceOf[IndexedSeq[T]] | |
} | |
val a = Array(1,2,3) //> a : Array[Int] = Array(1, 2, 3) |