Documentation
¶
Overview ¶
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
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().
func CreateFromArray ¶
func CreateFromArray(list []interface{}) Set
CreateFromArray creates Set with `DefinitelyFinite() == true` from an arbitrary list of elements.
func CreateFromFunc ¶
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.
func Difference ¶
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.
func Intersection ¶
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.