Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Hands on the Combinations class in Apache Commons Math

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

%classpath add mvn org.apache.commons commons-math3 3.6.1
Loading...
Loading...
import org.apache.commons.math3.util.Combinations
import scala.collection.JavaConverters._
import org.apache.commons.math3.util.Combinations import scala.collection.JavaConverters._
val it = new Combinations(6, 2).iterator()
it.foreach(System.out.println)
<console>:97: error: value foreach is not a member of java.util.Iterator[Array[Int]]
       it.foreach(System.out.println)
          ^
val it = new Combinations(5, 3).iterator()
while(it.hasNext()){
    System.out.print(it.next().mkString(" ") + "\n")
}
0 1 2
0 1 3
0 2 3
1 2 3
0 1 4
0 2 4
1 2 4
0 3 4
1 3 4
2 3 4
null