Created
June 12, 2015 07:52
-
-
Save zaltoprofen/e87baafb19a01571ffa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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