set

package module
v0.0.0-...-ab82884 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2017 License: GPL-3.0 Imports: 1 Imported by: 0

README

Build Status Coverage Status GoDoc

Description

This is a go library to work with finite and infinite sets.

Installation

This library is go-gettable. To install it simply run:

go get github.com/shaardie/set

Documentation

The documentation can be found under http://godoc.org/github.com/shaardie/set

Author

Sven Haardiek sven@haardiek.de

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

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

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

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL