2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
7
Task/Power-set/Scala/power-set-3.scala
Normal file
7
Task/Power-set/Scala/power-set-3.scala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def powerset[A](s: Set[A]) = {
|
||||
def powerset_rec(acc: List[Set[A]], remaining: List[A]): List[Set[A]] = remaining match {
|
||||
case Nil => acc
|
||||
case head :: tail => powerset_rec(acc ++ acc.map(_ + head), tail)
|
||||
}
|
||||
powerset_rec(List(Set.empty[A]), s.toList)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue