set: github.com/shaardie/set Index | Files

package set

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.

Index

Package Files

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

type Set Uses

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 Uses

func CreateFromArray(list []interface{}) Set

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

func CreateFromFunc Uses

func CreateFromFunc(f func(interface{}) (bool, error)) Set

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 Uses

func Difference(a Set, b Set) (Set, error)

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 Uses

func Intersection(a Set, b Set) (Set, error)

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.

func Join Uses

func Join(a Set, b Set) (Set, error)

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.