Lurch Deductive Engine

Class

Set

new Set()

The functions below extend the built-in Set class with new functionality.

Source

Methods

equals(other) → {boolean}

In mathematics, two sets $A$ and $B$ are equal if and only if $\forall x,(x\in A\text{ iff }x\in B)$. That is, they have exactly the same members. This function implements that definition.

Parameters

  • other Set

    the set to compare with this one for equality

Returns

  • boolean

    whether the two sets have exactly the same elements

Source

isSubset(other) → {boolean}

The usual $\subseteq$ relation from mathematics. Test whether this set is a subset of the other passed as a parameter, returning true/false.

Parameters

  • other Set

    the set to be tested for whether this set is a subset of it

See

Returns

  • boolean

    whether this set is a subset of other

Source

isSuperset(other) → {boolean}

The usual $\supseteq$ relation from mathematics. Test whether this set is a superset of the other passed as a parameter, returning true/false.

Parameters

  • other Set

    the set to be tested for whether this set is a superset of it

Returns

  • boolean

    whether this set is a superset of other

Source

subset(predicate) → {Set}

Construct a subset of this set, using precisely those elements that pass the given predicate. This is analogous to taking a set $S$ and forming a subset as we do with the mathematical notation $\{x\in S\mid P(x)\}$.

NOTE: This is not the "is a subset of" relation! This is a tool for computing subsets. If you'd like to check whether one set is a subset of another, see isSubset().

Parameters

  • predicate function

    the predicate that elements must pass in order to be included in the subset; it will be evaluated on every element of this set and should return a boolean

Returns

  • Set

    the subset of this set containing just those elements that satisfy the given predicate

Source

symmetricDifference(other) → {Set}

The usual set-theoretic symmetric difference of two sets, this one and any other, passed as the first parameter. The symmetric difference of sets $A$ and $B$, in usual mathematical notation, is $(A-B)\cup(B-A)$.

Parameters

  • other Set

    the set with which to compute the symmetric difference with this one

Returns

  • Set

    the symmetric difference of this set with the other

Source