-
code
scala> def bitmap(n: Int) = | for { i <- 1 until Math.pow(2, n).toInt | bitmap = (0 to n).map(j => (i >> j) & 0x1) | } yield bitmap
bitmap: (n: Int)scala.collection.immutable.IndexedSeq[scala.collection.immutable.IndexedSeq[Int]]
scala> bitmap(3) res39: scala.collection.immutable.IndexedSeq[scala.collection.immutable.IndexedSeq[Int]] = Vector(Vector(1, 0, 0, 0), Vector(0, 1, 0, 0), Vector(1, 1, 0, 0), Vector(0, 0, 1, 0), Vector(1, 0, 1, 0), Vector(0, 1, 1, 0), Vector(1, 1, 1, 0))
* code for bitmap indices
```scala
scala> def bitmapIndex(n: Int) =
| for { i <- 1 until Math.pow(2, n).toInt
| bitmap = (0 to n).map(j => (i >>j) & 0x1)
| index = bitmap zip (0 to n) filter (_._1 == 1) map (_._2)
| } yield index
bitmapIndex: (n: Int)scala.collection.immutable.IndexedSeq[scala.collection.immutable.IndexedSeq[Int]]
scala> bitmapIndex(3)
res48: scala.collection.immutable.IndexedSeq[scala.collection.immutable.IndexedSeq[Int]] = Vector(Vector(0), Vector(1), Vector(0, 1), Vector(2), Vector(0, 2), Vector(1, 2), Vector(0, 1, 2))