Jump to content

Power set: Difference between revisions

13 bytes removed ,  13 years ago
m
→‎Recursive: subheading change
(added Icon/Unicon example)
m (→‎Recursive: subheading change)
Line 767:
=={{header|Icon}} and {{header|Unicon}}==
 
===RecursiveSet building===
 
The following version returns a set containing the powerset:
Line 779:
head := ?s # take a random element
# and find powerset of remaining part of set
tail_pset := power_set (deletex -- set(copy(s), head))
result ++:= tail_pset # add powerset of remainder to results
every ps := !tail_pset do # and add head to each powerset from the remainder
insert (result, insertps ++ set(copy(ps), head))
}
return result
342

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.