skim

package
v0.0.0-...-a54ad32 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2017 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Quote      = Symbol("quote")
	Quasiquote = Symbol("quasiquote")
	Unquote    = Symbol("unquote")
)

Variables

This section is empty.

Functions

func IsNil

func IsNil(a Atom) bool

func IsTrue

func IsTrue(a Atom) bool

func Traverse

func Traverse(a Atom, visitor Visitor) (err error)

Traverse will recursively visit all cons pairs and left and right elements, in order. Traversal ends when a visitor returns a nil visitor for nested elements and all adjacent and upper elements are traversed. If a Vector is encountered, the vector itself is passed to the visitor function followed by its elements (passed to the visitor returned for the Vector).

func Walk

func Walk(a Atom, fn func(Atom) error) error

Walk recursively visits all cons pairs in a singly-linked list, calling fn for the car of each cons pair and walking through each cdr it encounters a nil cdr. If a cdr is encountered that is neither a cons pair nor nil, Walk returns an error. If the atom, a, is a Vector, it will call fn for each element of the vector.

Types

type Atom

type Atom interface {
	// SkimAtom is an empty method -- it exists only to mark a type as an Atom at compile time.
	SkimAtom()
	String() string
}

Atom defines any value understood to be a member of a skim list, including lists themselves.

func Caaaar

func Caaaar(a Atom) (Atom, error)

func Caaadr

func Caaadr(a Atom) (Atom, error)

func Caaar

func Caaar(a Atom) (Atom, error)

func Caadar

func Caadar(a Atom) (Atom, error)

func Caaddr

func Caaddr(a Atom) (Atom, error)

func Caadr

func Caadr(a Atom) (Atom, error)

func Caar

func Caar(a Atom) (Atom, error)

func Cadaar

func Cadaar(a Atom) (Atom, error)

func Cadadr

func Cadadr(a Atom) (Atom, error)

func Cadar

func Cadar(a Atom) (Atom, error)

func Caddar

func Caddar(a Atom) (Atom, error)

func Cadddr

func Cadddr(a Atom) (Atom, error)

func Caddr

func Caddr(a Atom) (Atom, error)

func Cadr

func Cadr(a Atom) (Atom, error)

func Car

func Car(a Atom) (Atom, error)

func Cdaaar

func Cdaaar(a Atom) (Atom, error)

func Cdaadr

func Cdaadr(a Atom) (Atom, error)

func Cdaar

func Cdaar(a Atom) (Atom, error)

func Cdadar

func Cdadar(a Atom) (Atom, error)

func Cdaddr

func Cdaddr(a Atom) (Atom, error)

func Cdadr

func Cdadr(a Atom) (Atom, error)

func Cdar

func Cdar(a Atom) (Atom, error)

func Cddaar

func Cddaar(a Atom) (Atom, error)

func Cddadr

func Cddadr(a Atom) (Atom, error)

func Cddar

func Cddar(a Atom) (Atom, error)

func Cdddar

func Cdddar(a Atom) (Atom, error)

func Cddddr

func Cddddr(a Atom) (Atom, error)

func Cdddr

func Cdddr(a Atom) (Atom, error)

func Cddr

func Cddr(a Atom) (Atom, error)

func Cdr

func Cdr(a Atom) (Atom, error)

func Dup

func Dup(a Atom) Atom

func List

func List(args ...Atom) Atom

func Map

func Map(list Atom, mapfn MapFunc) (result Atom, err error)

Map iterates over a list and maps its values using mapfn. It returns a new list with the mapped values. The input list must be, strictly, a list -- that is, all Cdrs of the input list must either be nil or another cons cell meeting the same criteria.

func Pair

func Pair(a Atom) (lhs, rhs Atom, err error)

type Bool

type Bool bool

func (Bool) SkimAtom

func (Bool) SkimAtom()

func (Bool) String

func (b Bool) String() string

type Cons

type Cons struct{ Car, Cdr Atom }

func (*Cons) Dup

func (c *Cons) Dup() Atom

func (*Cons) GoString

func (c *Cons) GoString() string

func (*Cons) Map

func (c *Cons) Map(fn MapFunc) (result Atom, err error)

func (*Cons) SkimAtom

func (*Cons) SkimAtom()

func (*Cons) String

func (c *Cons) String() string

type Dupper

type Dupper interface {
	Atom

	Dup() Atom
}

Dupper is an interface for cloneable atoms. The Dup method returns a deep clone of an atom. Any atom not implementing this is assumed to be un-clone-able and should be treated as a value (i.e., does not need to be cloned).

type Float

type Float float64

func (Float) Float64

func (f Float) Float64() (float64, bool)

func (Float) Int64

func (f Float) Int64() (int64, bool)

func (Float) IsFloat

func (Float) IsFloat() bool

func (Float) SkimAtom

func (Float) SkimAtom()

func (Float) String

func (f Float) String() string

type Int

type Int int64

func (Int) Float64

func (i Int) Float64() (float64, bool)

func (Int) Int64

func (i Int) Int64() (int64, bool)

func (Int) IsFloat

func (Int) IsFloat() bool

func (Int) SkimAtom

func (Int) SkimAtom()

func (Int) String

func (i Int) String() string

type MapFunc

type MapFunc func(Atom) (Atom, error)

MapFunc is a function used to map an atom to another atom. It may return an error, in which case the caller should assume the result atom is unusable unless documented otherwise for special uses of a specific MapFunc.

func (MapFunc) Map

func (fn MapFunc) Map(atom Atom) (Atom, error)

type Mapper

type Mapper interface {
	Map(MapFunc) (Atom, error)
}

type Numeric

type Numeric interface {
	Atom

	IsFloat() bool
	Int64() (int64, bool)
	Float64() (float64, bool)
}

type String

type String string

func (String) GoString

func (s String) GoString() string

func (String) SkimAtom

func (String) SkimAtom()

func (String) String

func (s String) String() string

type Symbol

type Symbol string

func (Symbol) GoString

func (s Symbol) GoString() string

func (Symbol) SkimAtom

func (Symbol) SkimAtom()

func (Symbol) String

func (s Symbol) String() string

type Vector

type Vector []Atom

func (Vector) Dup

func (v Vector) Dup() Atom

func (Vector) GoString

func (v Vector) GoString() string

func (Vector) Map

func (v Vector) Map(fn MapFunc) (result Atom, err error)

func (Vector) SkimAtom

func (Vector) SkimAtom()

func (Vector) String

func (v Vector) String() string

type Visitor

type Visitor func(Atom) (Visitor, error)

Jump to

Keyboard shortcuts

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