Jump to content

Power set: Difference between revisions

→‎{{header|PARI/GP}}: Add forsubset example
(→‎{{header|PARI/GP}}: Add forsubset example)
Line 2,152:
=={{header|PARI/GP}}==
<lang parigp>vector(1<<#S,i,vecextract(S,i-1))</lang>
 
In 2.10, the <code>forsubset</code> iterator was added to efficiently iterate over combinations and power sets.
<lang parigp>S=["a","b","c"]
forsubset(#S,s,print1(vecextract(S,s)" "))</lang>
{{out}}
<pre>[] ["a"] ["b"] ["c"] ["a", "b"] ["a", "c"] ["b", "c"] ["a", "b", "c"]</pre>
 
=={{header|Perl}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.