Skip to content

Instantly share code, notes, and snippets.

@johnelf
Created March 31, 2014 06:42
Show Gist options
  • Save johnelf/9886565 to your computer and use it in GitHub Desktop.
Save johnelf/9886565 to your computer and use it in GitHub Desktop.
def printList(args: TraversableOnce[_]): Unit = {
args.foreach(print)
println()
}
def count(ls: List[Int]): Unit = {
def doCount(src: List[Int], res: List[Int]): Unit = src match {
case Nil => printList(res)
case _ => for (element <- src) {
doCount(src.diff(List(element)), res :+ element)
}
}
doCount(ls, List());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment