circuit

package
v0.0.0-...-7c63792 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultValve = ""

DefaultValve is the name of the default valve

View Source
const Super = ""

Super is the super-gates name. The super-gate is the gate-view of the current/top-most circuit.

Variables

This section is empty.

Functions

func IsLetter

func IsLetter(n Name) bool

func IsNumber

func IsNumber(n Name) bool

func IsSymbol

func IsSymbol(n Name) bool

func IsVerb

func IsVerb(v Value) bool

IsVerb returns true if the supplied value is a verb

func Linearize

func Linearize(s string) string

func NameString

func NameString(n Name) string

func Print

func Print(w io.Writer, f Format, v Value)

func QuickPrint

func QuickPrint(prefix, indent string, recurse int, v Value) string

func Same

func Same(x, y Value) bool

Same checks whether the two supplied values are the same. See `Value.Same()`

func SortNames

func SortNames(names []Name)

SortNames sorts the argument slice of names, prioritizing strings before ints and everything else after.

func String

func String(v Value) string

Types

type Circuit

type Circuit struct {
	Gate map[Name]Value
	Flow map[Name]map[Name]Vector // gate -> valve -> opposing gate and valve
}

Circuit represents an Escher circuit. See the Escher Handbook for a description of circuits.

func New

func New() Circuit

New creates a new circuit without gates nor flows

func (Circuit) Abandon

func (u Circuit) Abandon(name Name) Circuit

func (Circuit) At

func (u Circuit) At(name Name) Value

At returns the value of the gate with the supplied name

func (Circuit) CircuitAt

func (u Circuit) CircuitAt(name Name) Circuit

func (Circuit) CircuitOptionAt

func (u Circuit) CircuitOptionAt(name Name) (Circuit, bool)

func (Circuit) ComplexAt

func (u Circuit) ComplexAt(name Name) complex128

func (Circuit) Copy

func (u Circuit) Copy() Circuit

func (Circuit) DeepCopy

func (u Circuit) DeepCopy() Circuit

func (Circuit) Degree

func (u Circuit) Degree(gate Name) int

Degree returns the number of connected valves of the gate with the supplied name

func (Circuit) Exclude

func (u Circuit) Exclude(name Name) (forgotten Value)

func (Circuit) FloatAt

func (u Circuit) FloatAt(name Name) float64

func (Circuit) FloatOrZeroAt

func (u Circuit) FloatOrZeroAt(name Name) float64

FloatOrZeroAt returns the value of the gate with the supplied name if it is a float value, 0.0 otherwise

func (Circuit) Flows

func (u Circuit) Flows() (r [][2]Vector)

func (Circuit) Follow

func (u Circuit) Follow(v Vector) Vector

Follow returns the vector linked up with the supplied vector

func (Circuit) Forget

func (u Circuit) Forget(addr []Name) Value

func (Circuit) Gates

func (u Circuit) Gates() map[Name]Value

Gates returns a map of gate IDs to their values

func (Circuit) Goto

func (u Circuit) Goto(gate ...Name) Value

func (Circuit) Grow

func (u Circuit) Grow(name Name, value Value) Circuit

func (Circuit) Has

func (u Circuit) Has(name Name) bool

func (Circuit) Include

func (u Circuit) Include(name Name, value Value) (before Value)

func (Circuit) IntAt

func (u Circuit) IntAt(name Name) int

func (Circuit) IntOptionAt

func (u Circuit) IntOptionAt(name Name) (int, bool)

func (Circuit) IntOrZeroAt

func (u Circuit) IntOrZeroAt(name Name) int

IntOrZeroAt returns the value of the gate with the supplied name if it is an int value, 0 otherwise

func (Circuit) IsEmpty

func (u Circuit) IsEmpty() bool

IsEmpty checks whether the argument circuit has no gates nor flows

func (Circuit) IsNil

func (u Circuit) IsNil() bool

IsNil checks whether the argument circuit is uninitialized

func (Circuit) Len

func (u Circuit) Len() int

Len returns the number of gates in a circuit

func (Circuit) Letters

func (u Circuit) Letters() []string

Letters returns a list of all gate IDs that are strings

func (u Circuit) Link(x, y Vector)

Link connects two different, yet unconnected valves (by vector), potentially from the same gate

func (Circuit) Lookup

func (u Circuit) Lookup(addr []Name) (v Value)

func (Circuit) Merge

func (u Circuit) Merge(v Circuit)

func (Circuit) NameAt

func (u Circuit) NameAt(name Name) Name

TODO ... and more below

func (Circuit) Names

func (u Circuit) Names() []Name

Names returns a list of all gate IDs (whether they are string or int)

func (Circuit) Numbers

func (u Circuit) Numbers() []int

Numbers returns a list of all gate IDs that are ints

func (Circuit) OptionAt

func (u Circuit) OptionAt(name Name) (Value, bool)

TODO

func (Circuit) Place

func (u Circuit) Place(addr []Name, value Value) Value

func (Circuit) Print

func (u Circuit) Print(w io.Writer, f Format)

func (Circuit) ReGrow

func (u Circuit) ReGrow(name Name, value Value) Circuit

func (Circuit) RePlace

func (u Circuit) RePlace(addr []Name, value Value) Value

func (Circuit) Refine

func (u Circuit) Refine(walk ...Name) Circuit

func (Circuit) Reflow

func (u Circuit) Reflow(s, t Name)

func (Circuit) Rename

func (u Circuit) Rename(x, y Name) Circuit

func (Circuit) Same

func (x Circuit) Same(v Value) bool

func (Circuit) SortedLetters

func (u Circuit) SortedLetters() []string

SortedLetters returns a sorted list of all gate IDs that are strings

func (Circuit) SortedNames

func (u Circuit) SortedNames() []Name

SortedNames returns a sorted list of all gate IDs (whether they are string or int)

func (Circuit) SortedNumbers

func (u Circuit) SortedNumbers() []int

SortedNumbers returns a sorted list of all gate IDs that are ints

func (Circuit) String

func (u Circuit) String() string

func (Circuit) StringAt

func (u Circuit) StringAt(name Name) string

func (Circuit) StringOptionAt

func (u Circuit) StringOptionAt(name Name) (string, bool)

func (Circuit) Unify

func (u Circuit) Unify(name string) string

Unify creates a most simple string to narrowly identify a circuit by its (supplied) name and number of gates

func (u Circuit) Unlink(x, y Vector)

Unlink removes the link between two Vectors

func (Circuit) ValveNames

func (u Circuit) ValveNames(gate Name) []Name

ValveNames returns the list of connected valve-names of the gate with the supplied name

func (Circuit) Valves

func (u Circuit) Valves(gate Name) map[Name]Vector

Valves returns the list of connected valve-name of the gate with the supplied name, and their connected vectors

func (Circuit) VectorAt

func (u Circuit) VectorAt(name Name) Vector

func (Circuit) VerbAt

func (u Circuit) VerbAt(name Name) Verb

func (Circuit) View

func (u Circuit) View(gate Name) Circuit

View returns a copy of this circuit reduced to the supplied gate

func (Circuit) Vol

func (u Circuit) Vol() (vol int)

Vol counts the number of connected valves within this circuit

type Format

type Format struct {
	Prefix  string
	Indent  string
	Recurse int
}

type Name

type Name interface{}

Name represents a gate name within a circuit.

type Orient

type Orient map[Name]map[Name]struct{} // gate -> valve -> yes/no?

Orient is a registry for gates names and their valve names

func (Orient) Has

func (o Orient) Has(gate, valve Name) bool

Has returns true if the gate supplied by name has a valve with the supplied name

func (Orient) Include

func (o Orient) Include(gate, valve Name)

Include registers the gate supplied by name as having the supplied valve name

type Value

type Value interface{}

Value is one of: string, int, float64, complex128, Circuit

func Copy

func Copy(x Value) (y Value)

Copy creates a shallow copy of the supplied value

func DeepCopy

func DeepCopy(x Value) (y Value)

DeepCopy creates a deep copy of the supplied value

type Vector

type Vector struct {
	Gate  Name
	Valve Name
}

Vector identifies a specific valve of a gate (== instance of a circuit)

func (Vector) String

func (v Vector) String() string

String prints a string representation of the vector

type Verb

type Verb Circuit

Verb is an interpretation of a circuit. The values of the sorted, number-named gates are treated as a slice of values representing an ‘address’. The value of the empty-string gate, if present, is expected to be a string and is a ‘verb’ word.

func NewAddress

func NewAddress(addr ...Name) Verb

NewAddress returns a verb-view circuit (like an array in other languages) of the supplied names in the supplied order.

func NewVerbAddress

func NewVerbAddress(verb string, addr ...Name) Verb

NewVerbAddress returns a verb-view circuit (like an array in other languages) with the given name and the supplied names in the supplied order

func (Verb) Address

func (verb Verb) Address() (addr []Name)

func (Verb) Print

func (verb Verb) Print(w io.Writer, f Format)

func (Verb) String

func (verb Verb) String() string

func (Verb) Verb

func (verb Verb) Verb() Value

Jump to

Keyboard shortcuts

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