boolean

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: CC0-1.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrArgNotABoolean = objectError(iota)
	ErrArg1NotABoolean
	ErrArg2NotABoolean
)

Common errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algebra

type Algebra interface {
	object.Parent
	// True returns the value corresponding to true.
	True() object.Element
	// False returns the value corresponding to false.
	False() object.Element
	// IsTrue returns true iff x is equal to the value corresponding to true.
	IsTrue(x object.Element) (bool, error)
	// IsFalse returns true iff x is equal to the value corresponding to false.
	IsFalse(x object.Element) (bool, error)
	// And returns the result x AND y.
	And(x object.Element, y object.Element) (object.Element, error)
	// Or returns the result x OR y.
	Or(x object.Element, y object.Element) (object.Element, error)
	// Not returns the negation NOT x.
	Not(x object.Element) (object.Element, error)
}

Algebra is the interface satisfied by a boolean algebra.

type Element

type Element bool

Element satisfies the object.Element interface.

func FromString

func FromString(s string) (Element, error)

FromString returns the boolean represented by the string s.

func ToElement

func ToElement(x object.Element) (Element, error)

ToElement attempts to convert the argument to an Element.

func (Element) Hash

func (b Element) Hash() uint32

Hash return the hash value.

func (Element) Parent

func (b Element) Parent() object.Parent

Parent returns the parent object for the boolean. This can safely be coerced to type Parent.

func (Element) String

func (b Element) String() string

String returns "true" if the boolean is true, "false" otherwise.

type Parent

type Parent struct{}

Parent is the parent of a boolean element.

func Booleans

func Booleans() Parent

Booleans returns the parent object for boolean values.

func (Parent) And

And returns the result x AND y.

func (Parent) AreEqual

func (B Parent) AreEqual(x object.Element, y object.Element) (bool, error)

AreEqual returns true iff x equals y.

func (Parent) Cmp

func (B Parent) Cmp(x object.Element, y object.Element) (int, error)

Cmp returns -1 if x is false and y is true, 0 if x == y, and +1 if x is true and y is false.

func (Parent) Contains

func (B Parent) Contains(x object.Element) bool

Contains returns true iff x is a boolean.

func (Parent) False

func (B Parent) False() object.Element

False returns the value corresponding to false.

func (Parent) IsFalse

func (B Parent) IsFalse(x object.Element) (bool, error)

IsFalse returns true iff x is equal to the value corresponding to false.

func (Parent) IsTrue

func (B Parent) IsTrue(x object.Element) (bool, error)

IsTrue returns true iff x is equal to the value corresponding to true.

func (Parent) Not

func (B Parent) Not(x object.Element) (object.Element, error)

Not returns the negation NOT x.

func (Parent) Or

Or returns the result x OR y.

func (Parent) String

func (B Parent) String() string

String returns a string description of the space of booleans.

func (Parent) ToElement

func (B Parent) ToElement(x object.Element) (object.Element, error)

ToElement returns x as an element of this parent, or an error if x cannot naturally be regarded as an element of this parent.

func (Parent) True

func (B Parent) True() object.Element

True returns the value corresponding to true.

Jump to

Keyboard shortcuts

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