Skip to content

Instantly share code, notes, and snippets.

@zaltoprofen
Created June 12, 2015 07:52
Show Gist options
  • Save zaltoprofen/e87baafb19a01571ffa2 to your computer and use it in GitHub Desktop.
Save zaltoprofen/e87baafb19a01571ffa2 to your computer and use it in GitHub Desktop.
object Application extends App {
def power[A](s: Set[A]): Set[Set[A]] = {
@annotation.tailrec
def go(a: Set[A], b: Set[Set[A]]): Set[Set[A]] = {
if (a.isEmpty) b
else go(a.tail, b.map(_ + a.head) ++ b)
}
go(s, Set(Set()))
}
val s = Set("帰", "る")
val ps = power(s).filter(_ => util.Random.nextBoolean)
println(ps)
if (ps.size < 4) println("帰る冪でない")
else println("帰る冪である")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment