CoCoA:Subsets

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Subsets

returns all sublists of a list

Description

This function computes all sublists (subsets) of a list (set).

If N is specified, it computes all sublists of cardinality N.

Example

  Subsets([1, 4, 7]);
[[ ], [7], [4], [4, 7], [1], [1, 7], [1, 4], [1, 4, 7]]
-------------------------------
  Subsets([1, 4, 7], 2);
[[1, 4], [1, 7], [4, 7]]
-------------------------------
  Subsets([2,3,3]);                 -- list with repeated entries
[[ ], [3], [3], [3, 3], [2], [2, 3], [2, 3], [2, 3, 3]]
-------------------------------
  Subsets(MakeSet([2,3,3]));
[[ ], [3], [2], [2, 3]]
-------------------------------

Syntax

Subsets(S:LIST):LIST
Subsets(S:LIST, N:INT):LIST

IsSubset

Partitions

Permutations

MakeSet

Tuples

   <type>list</type>