def powerset( {} ) = {{}} powerset( s ) = acc = powerset( s.tail() ) acc + map( x -> {s.head()} + x, acc )