Power set: Difference between revisions
→Logical (cut-free) Definition: clarify meaning of efficiency
m (→Logical (cut-free) Definition: remove redundant comment) |
(→Logical (cut-free) Definition: clarify meaning of efficiency) |
||
Line 1,712:
The predicate subseq(X,Y) is true if and only if the list X is a subsequence of the list Y.
The
<lang Prolog>powerset(X,Y) :- bagof( S, subseq(S,X), Y).
subseq( [], []).
Line 1,722 ⟶ 1,721:
</lang>
Output :
<pre> ?- powerset([1,2,3], X).▼
▲?- powerset([1,2,3], X).
X = [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]].
</pre>
|