progs/fun/funt.sc
changeset 1036 b84e794b9e88
parent 1031 b62c0002c735
--- a/progs/fun/funt.sc	Thu Dec 04 21:33:25 2025 +0000
+++ b/progs/fun/funt.sc	Thu Dec 11 12:34:03 2025 +0000
@@ -16,6 +16,14 @@
 // the first prints out the JVM instructions
 // the second runs the generated class files
 
+def powerset(xs: Set[Int]) : Set[Set[Int]] = {
+  if (xs == Set()) Set(Set())
+  else { val subs = powerset(xs.tail)
+     subs ++ subs.map(_ + xs.head)
+  }
+}
+
+powerset(Set(1,2,3))
 
 import $file.fun_tokens, fun_tokens._
 import $file.fun_parser, fun_parser._