tristate

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

tristate is a helper package for tri-state boolean logic, which is used for logical combinator components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool int

Bool is a tri-state boolean: False, True or Unknown.

Operations use truth tables as in https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics.

const (
	// False is definitely false.
	False Bool = 0

	// Unknown is "maybe false, maybe true".
	Unknown Bool = 1

	// True is definitely true.
	True Bool = 2
)

func FromReading

func FromReading(reading runtime.Reading) Bool

FromReading interprets runtime.Reading as Bool, mapping 0 to False, any valid non-zero to True and Invalid to Unknown.

(It's the same mapping as in ToReading, but allowing more truthy values).

func (Bool) And

func (b Bool) And(rhs Bool) Bool

And implements "logical and with indeterminacy".

func (Bool) IsFalse

func (b Bool) IsFalse() bool

IsFalse returns true if Bool is False.

func (Bool) IsTrue

func (b Bool) IsTrue() bool

IsTrue returns true if Bool is True.

func (Bool) IsUnknown

func (b Bool) IsUnknown() bool

IsUnknown returns true if Bool is Unknown.

func (Bool) Not

func (b Bool) Not() Bool

Not returns result of logical negation.

func (Bool) Or

func (b Bool) Or(rhs Bool) Bool

Or implements "logical or with indeterminacy".

func (Bool) ToReading

func (b Bool) ToReading() runtime.Reading

ToReading converts tri-state Bool to runtime.Reading, mapping False to 0, True to 1 and Unknown to invalid reading.

Jump to

Keyboard shortcuts

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