We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Rick Bhowmick • 10 years ago

I have some shorter Scala implementations [here](https://github.com/pathikri... )

Some minor name changes:
"xcombinations" is "repeatedComvinations"
"xsubsets" is "combinations"
"xvariations" is "repeatedCombinations map nextPermuation:
"permutations" is "nextPermuratation"

Vladimir Kostyukov • 10 years ago

Thanks for the link! That's a nice tutorial to follow. I especially like the way you used for comprehension in the implementations.

Aamir Fayaz • 6 years ago

object IntOps {
implicit class ExtendedInt(n: Int) {
def times(fn: Unit => Unit): Unit =
(0 until n).foreach(fn)
}
}
above code is not compiling, for Range foreach is of type (f: Int => U)
this compiles fine:

object IntOps {
implicit class ExtendedInt(n: Int) {
def times(fn: Int => Unit): Unit =
(0 until n).foreach(fn)
}
}

object IntOpsTest extends App {
import IntOps._
5.times{ _ => println("hi") }
}

David • 8 years ago

I think this is a bug: xcombinations(0) returns List(); but it should return List(List()).