Power set: Difference between revisions

m
added whitespace to the task's preamble.
m (→‎{{header|REXX}}: reintroduced original whitespace to the output section, add/changed comments.)
m (added whitespace to the task's preamble.)
Line 1:
{{task|Discrete math}}
{{omit from|GUISS}}
 
A [[set]] is a collection (container) of certain values,
without any particular order, and no repeated values.
Line 8 ⟶ 9:
 
Given a set S, the [[wp:Power_set|power set]] (or powerset) of S, written P(S), or 2<sup>S</sup>, is the set of all subsets of S.<br />
 
'''Task : ''' By using a library or built-in set type, or by defining a set type with necessary operations, write a function with a set S as input that yields the power set 2<sup>S</sup> of S.
 
;Task:
'''Task : ''' By using a library or built-in set type, or by defining a set type with necessary operations, write a function with a set S as input that yields the power set 2<sup>S</sup> of S.
 
 
For example, the power set of {1,2,3,4} is {{}, {1}, {2}, {1,2}, {3}, {1,3}, {2,3}, {1,2,3}, {4}, {1,4}, {2,4}, {1,2,4}, {3,4}, {1,3,4}, {2,3,4}, {1,2,3,4}}.
Line 15 ⟶ 20:
 
The power set of the empty set is the set which contains itself (2<sup>0</sup> = 1):<br />
::: <math>\mathcal{P}</math>(<math>\varnothing</math>) = { <math>\varnothing</math> }<br />
 
And the power set of the set which contains only the empty set, has two subsets, the empty set and the set which contains the empty set (2<sup>1</sup> = 2):<br />
::: <math>\mathcal{P}</math>({<math>\varnothing</math>}) = { <math>\varnothing</math>, { <math>\varnothing</math> } }<br>
 
 
'''Extra credit: ''' Demonstrate that your language supports these last two powersets.
<br><br>
 
=={{header|Ada}}==