`import "github.com/shaardie/set"`

Package set provides functions and an interface to work with sets of finite or infinite mathematical sets. There is a distinction between definitely finite sets which provides an explicit representation and non definitely finite sets which are lacking some functionality and performance but are able to handle infinite sets.

create.go difference.go doc.go elementSet.go functionSet.go interface.go intersection.go join.go

❖

type Set interface { Contains(x interface{}) (bool, error) Countable() bool DefinitelyFinite() bool Cardinality() (uint64, error) List() ([]interface{}, error) }

Set implements an interface to various implementations of sets.

DefinitelyFinite() implements the indicator for a set to be definitely finite. But caution: `DefinitlyFinite() == false` does not mean that this set could not be finite, too. Definitely finite sets have the ability to count their elements and show them explicit in arrays. Therefore, definitely finite set implementations should also implement Cardinality() and List() since those will be used by functions like Difference(a Set, b Set) to be able to speed up the handling of sets. Countable() is deprecated. Better use DefinitelyFinite().

CreateFromArray creates Set with `DefinitelyFinite() == true` from an arbitrary list of elements.

CreateFromFunc creates a Set with `DefinitelyFinite() == false` from a function which indicates if the given element is contained in the set.

To better support complex function it is possible to define an error which is passed through the other functions like Interception to ease error handling.

Difference creates a set as the difference of the sets a and b.

If the set a is definitely finite the resulting set is also definitely finite and if a is not definitely finite the resulting set is not also.

Intersection creates a set as the intersection of the sets a and b.

If a or b are definitely finite the resulting set is also definitely finite. Otherwise the resulting set is not definitely finite. So this function is an excellent way to make sets definitely finite.

Join creates a set as the join of the sets a and b.

If a and b are definitely finite the resulting set is also definitely finite. Otherwise the resulting set not definitely finite.

Package set imports 1 packages (graph). Updated 2017-01-17. Refresh now. Tools for package owners.