# SetAggregate SΒΆ

- S: SetCategory

A set category lists a collection of set-theoretic operations useful for both finite sets and multisets. Note however that finite sets are distinct from multisets. Although the operations defined for set categories are common to both, the relationship between the two cannot be described by inclusion or inheritance.

- #: % -> NonNegativeInteger if % has finiteAggregate
- from Aggregate
- <: (%, %) -> Boolean
- from PartialOrder
- <=: (%, %) -> Boolean
- from PartialOrder
- =: (%, %) -> Boolean
- from BasicType
- >: (%, %) -> Boolean
- from PartialOrder
- >=: (%, %) -> Boolean
- from PartialOrder
- ~=: (%, %) -> Boolean
- from BasicType
- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
- from HomogeneousAggregate S
- coerce: % -> OutputForm
- from CoercibleTo OutputForm
- construct: List S -> %
- from Collection S
- convert: % -> InputForm if S has ConvertibleTo InputForm
- from ConvertibleTo InputForm
- copy: % -> %
- from Aggregate
- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
- from HomogeneousAggregate S
- count: (S, %) -> NonNegativeInteger if % has finiteAggregate
- from HomogeneousAggregate S

- difference: (%, %) -> %
`difference(u, v)`

returns the set aggregate`w`

consisting of elements in set aggregate`u`

but not in set aggregate`v`

. If`u`

and`v`

have no elements in common,`difference(u, v)`

returns a copy of`u`

. Note: equivalent to the notation (not currently supported)`[x for x in u | not member?(x, v)]`

.

- difference: (%, S) -> %
`difference(u, x)`

returns the set aggregate`u`

with element`x`

removed. If`u`

does not contain`x`

, a copy of`u`

is returned. Note:`difference(s, x) = difference(s, set [x])`

.- empty: () -> %
- from Aggregate
- empty?: % -> Boolean
- from Aggregate
- eq?: (%, %) -> Boolean
- from Aggregate
- eval: (%, Equation S) -> % if S has Evalable S
- from Evalable S
- eval: (%, List Equation S) -> % if S has Evalable S
- from Evalable S
- eval: (%, List S, List S) -> % if S has Evalable S
- from InnerEvalable(S, S)
- eval: (%, S, S) -> % if S has Evalable S
- from InnerEvalable(S, S)
- every?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
- from HomogeneousAggregate S
- find: (S -> Boolean, %) -> Union(S, failed)
- from Collection S
- hash: % -> SingleInteger
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState
- from SetCategory

- intersect: (%, %) -> %
`intersect(u, v)`

returns the set aggregate`w`

consisting of elements common to both set aggregates`u`

and`v`

. Note: equivalent to the notation (not currently supported) [`x`

for`x`

in`u`

| member?(`x`

,`v`

)].- latex: % -> String
- from SetCategory
- less?: (%, NonNegativeInteger) -> Boolean
- from Aggregate
- map!: (S -> S, %) -> % if % has shallowlyMutable
- from HomogeneousAggregate S
- map: (S -> S, %) -> %
- from HomogeneousAggregate S
- member?: (S, %) -> Boolean if % has finiteAggregate
- from HomogeneousAggregate S
- members: % -> List S if % has finiteAggregate
- from HomogeneousAggregate S
- more?: (%, NonNegativeInteger) -> Boolean
- from Aggregate
- parts: % -> List S if % has finiteAggregate
- from HomogeneousAggregate S
- reduce: ((S, S) -> S, %) -> S if % has finiteAggregate
- from Collection S
- reduce: ((S, S) -> S, %, S) -> S if % has finiteAggregate
- from Collection S
- reduce: ((S, S) -> S, %, S, S) -> S if % has finiteAggregate
- from Collection S
- remove: (S -> Boolean, %) -> % if % has finiteAggregate
- from Collection S
- remove: (S, %) -> % if % has finiteAggregate
- from Collection S
- removeDuplicates: % -> % if % has finiteAggregate
- from Collection S
- sample: %
- from Aggregate
- select: (S -> Boolean, %) -> % if % has finiteAggregate
- from Collection S

- set: () -> %
`set()`

$`D`

creates an empty set aggregate of type`D`

.

- set: List S -> %
`set([x, y, ..., z])`

creates a set aggregate containing items`x`

,`y`

, ...,`z`

.- size?: (%, NonNegativeInteger) -> Boolean
- from Aggregate

- subset?: (%, %) -> Boolean
`subset?(u, v)`

tests if`u`

is a subset of`v`

. Note: equivalent to`reduce(and, [member?(x, v) for x in members(u)], true, false)`

.

- symmetricDifference: (%, %) -> %
`symmetricDifference(u, v)`

returns the set aggregate of elements`x`

which are members of set aggregate`u`

or set aggregate`v`

but not both. If`u`

and`v`

have no elements in common,`symmetricDifference(u, v)`

returns a copy of`u`

. Note:`symmetricDifference(u, v) = union(difference(u, v), difference(v, u))`

- union: (%, %) -> %
`union(u, v)`

returns the set aggregate of elements which are members of either set aggregate`u`

or`v`

.

- union: (%, S) -> %
`union(u, x)`

returns the set aggregate`u`

with the element`x`

added. If`u`

already contains`x`

,`union(u, x)`

returns a copy of`u`

.

- union: (S, %) -> %
`union(x, u)`

returns the set aggregate`u`

with the element`x`

added. If`u`

already contains`x`

,`union(x, u)`

returns a copy of`u`

.

ConvertibleTo InputForm if S has ConvertibleTo InputForm

Evalable S if S has Evalable S

InnerEvalable(S, S) if S has Evalable S