Documentation ¶
Overview ¶
Package data provides basic interfaces, primitives and data structures
Index ¶
- Constants
- Variables
- func AnyArityChecker(int) error
- func AssertFixed(fixed, count int) int
- func AssertMinimum(min, count int) int
- func AssertRanged(min, max, count int) int
- func DumpString(v Value) string
- func Equal(l, r Value) bool
- func HashBytes(b []byte) uint64
- func HashCode(v Value) uint64
- func HashInt(i int) uint64
- func HashInt64(i int64) uint64
- func HashString(s string) uint64
- func MakeSequenceStr(s Sequence) string
- func ToQuotedString(v Value) string
- func ToString(v Value) string
- type Appender
- type ArityChecker
- type BigInt
- func (l *BigInt) Add(r Number) Number
- func (l *BigInt) Cmp(r Number) Comparison
- func (l *BigInt) Div(r Number) Number
- func (l *BigInt) Equal(r Value) bool
- func (l *BigInt) HashCode() uint64
- func (*BigInt) IsNaN() bool
- func (*BigInt) IsNegInf() bool
- func (*BigInt) IsPosInf() bool
- func (l *BigInt) Mod(r Number) Number
- func (l *BigInt) Mul(r Number) Number
- func (l *BigInt) String() string
- func (l *BigInt) Sub(r Number) Number
- func (*BigInt) Type() types.Type
- type Bool
- type Call
- type Caller
- type Comparison
- type Cons
- type Counted
- type CountedSequence
- type Float
- func (l Float) Add(r Number) Number
- func (l Float) Cmp(r Number) Comparison
- func (l Float) Div(r Number) Number
- func (l Float) Equal(r Value) bool
- func (l Float) HashCode() uint64
- func (l Float) IsNaN() bool
- func (l Float) IsNegInf() bool
- func (l Float) IsPosInf() bool
- func (l Float) Mod(r Number) Number
- func (l Float) Mul(r Number) Number
- func (l Float) String() string
- func (l Float) Sub(r Number) Number
- func (Float) Type() types.Type
- type Hashed
- type Indexed
- type IndexedSequence
- type Integer
- func (l Integer) Add(r Number) Number
- func (l Integer) Cmp(r Number) Comparison
- func (l Integer) Div(r Number) Number
- func (l Integer) Equal(r Value) bool
- func (l Integer) HashCode() uint64
- func (Integer) IsNaN() bool
- func (Integer) IsNegInf() bool
- func (Integer) IsPosInf() bool
- func (l Integer) Mod(r Number) Number
- func (l Integer) Mul(r Number) Number
- func (l Integer) String() string
- func (l Integer) Sub(r Number) Number
- func (Integer) Type() types.Type
- type Keyword
- type List
- func (l *List) Call(args ...Value) Value
- func (l *List) Car() Value
- func (l *List) Cdr() Value
- func (l *List) CheckArity(argc int) error
- func (l *List) Count() Integer
- func (l *List) ElementAt(index Integer) (Value, bool)
- func (l *List) Equal(other Value) bool
- func (l *List) HashCode() uint64
- func (l *List) IsEmpty() bool
- func (l *List) Prepend(v Value) Sequence
- func (l *List) Reverse() Sequence
- func (l *List) Split() (Value, Sequence, bool)
- func (l *List) String() string
- func (l *List) Type() types.Type
- type Local
- type Locals
- type Mapped
- type Mapper
- type Named
- type Number
- type Object
- func (o *Object) Call(args ...Value) Value
- func (o *Object) Car() Value
- func (o *Object) Cdr() Value
- func (o *Object) CheckArity(argc int) error
- func (o *Object) Count() Integer
- func (o *Object) Equal(other Value) bool
- func (o *Object) Get(k Value) (Value, bool)
- func (o *Object) HashCode() uint64
- func (o *Object) IsEmpty() bool
- func (o *Object) Pairs() Pairs
- func (o *Object) Put(p Pair) Sequence
- func (o *Object) Remove(k Value) (Value, Sequence, bool)
- func (o *Object) Split() (Value, Sequence, bool)
- func (o *Object) String() string
- func (*Object) Type() types.Type
- type Pair
- type Pairs
- type Prepender
- type Procedure
- type Qualified
- type RandomAccess
- type Ratio
- func (l *Ratio) Add(r Number) Number
- func (l *Ratio) Cmp(r Number) Comparison
- func (l *Ratio) Div(r Number) Number
- func (l *Ratio) Equal(r Value) bool
- func (l *Ratio) HashCode() uint64
- func (*Ratio) IsNaN() bool
- func (*Ratio) IsNegInf() bool
- func (*Ratio) IsPosInf() bool
- func (l *Ratio) Mod(r Number) Number
- func (l *Ratio) Mul(r Number) Number
- func (l *Ratio) String() string
- func (l *Ratio) Sub(r Number) Number
- func (*Ratio) Type() types.Type
- type Reverser
- type Sequence
- type String
- func (s String) Call(args ...Value) Value
- func (s String) Car() Value
- func (s String) Cdr() Value
- func (s String) CheckArity(argc int) error
- func (s String) Count() Integer
- func (s String) ElementAt(index Integer) (Value, bool)
- func (s String) Equal(other Value) bool
- func (s String) HashCode() uint64
- func (s String) IsEmpty() bool
- func (s String) Quote() string
- func (s String) Reverse() Sequence
- func (s String) Split() (Value, Sequence, bool)
- func (s String) String() string
- func (String) Type() types.Type
- type Symbol
- type SymbolGenerator
- type TypePredicate
- type Typed
- type Value
- type Vector
- func (v Vector) Append(e Value) Sequence
- func (v Vector) Call(args ...Value) Value
- func (v Vector) Car() Value
- func (v Vector) Cdr() Value
- func (v Vector) CheckArity(argc int) error
- func (v Vector) Count() Integer
- func (v Vector) ElementAt(index Integer) (Value, bool)
- func (v Vector) Equal(other Value) bool
- func (v Vector) HashCode() uint64
- func (v Vector) IndexOf(val Value) (int, bool)
- func (v Vector) IsEmpty() bool
- func (v Vector) Prepend(e Value) Sequence
- func (v Vector) Reverse() Sequence
- func (v Vector) Split() (Value, Sequence, bool)
- func (v Vector) String() string
- func (Vector) Type() types.Type
Constants ¶
const ( // ErrFixedArity is raised when there are too few or many arguments // provided to a fixed ArityChecker ErrFixedArity = "expected %d arguments, got %d" // ErrMinimumArity is raised when there are too few arguments provided to a // minimum ArityChecker ErrMinimumArity = "expected at least %d arguments, got %d" // ErrRangedArity is raised when there are too few or many arguments // provided to a ranged ArityChecker ErrRangedArity = "expected between %d and %d arguments, got %d" // ErrTooManyArguments is raised when there are too many arguments provided // to a maximum ArityChecker ErrTooManyArguments = "too many arity check arguments" )
const ( CountKey = Keyword("count") InstanceKey = Keyword("instance") NameKey = Keyword("name") TypeKey = Keyword("type") )
Standard Keys
const ( // ErrExpectedInteger is raised when the value provided to ParseInteger // can't be interpreted as an integer ErrExpectedInteger = "value is not an integer: %s" // ErrDivideByZero is raised when an attempt is made to perform integer // division by zero ErrDivideByZero = "divide by zero" )
const ( // ErrExpectedFloat is raised when a call to ParseFloat can't properly // interpret its input as a floating point number ErrExpectedFloat = "value is not a float: %s" // ErrExpectedRatio is raised when a call to ParseRatio can't properly // interpret its input as a ratio ErrExpectedRatio = "value is not a ratio: %s" )
const ( // ErrInvalidStartIndex is raised when an attempt to take a substring of a // String would result in a start index outside the String's actual range ErrInvalidStartIndex = "starting index is out of range: %d" // ErrInvalidEndIndex is raised when an attempt to take a substring of a // String would result in an end index beyond the String's actual range ErrInvalidEndIndex = "ending index is out of range: %d" // ErrEndIndexTooLow is raised when an attempt to take a substring of a // String specifies an ending index that is lower than the starting index ErrEndIndexTooLow = "ending index is lower than starting index: %d < %d" )
const ( // DomainSeparator is the character used to separate a domain from // the local component of a qualified symbol DomainSeparator = '/' SymbolGenDigits = decimal + lower + upper + "-+" )
const ( // True represents the boolean value of True True Bool = true // TrueLiteral represents the literal value of True TrueLiteral = "#t" // False represents the boolean value of false False Bool = false // FalseLiteral represents the literal value of False FalseLiteral = "#f" )
const EmptyString = String("")
EmptyString represents the... empty string
const ErrInvalidSymbol = "invalid symbol: %s"
ErrInvalidSymbol is raised when a call to ParseSymbol can't interpret its input as a proper Symbol name (local or qualified)
const ErrMapNotPaired = "map does not contain an even number of elements"
ErrMapNotPaired is raised when a call to ValuesToObject receives an odd number of args, meaning it won't be capable of zipping them into an Object
const OrMore = -1
OrMore is the constant used when you want to tell MakeChecker to generate a minimum arity checker
Variables ¶
var (
EmptyVector = Vector{}
)
EmptyVector represents an empty Vector
Functions ¶
func AnyArityChecker ¶
AnyArityChecker allows for any number of arguments
func AssertFixed ¶
AssertFixed explodes if a fixed arity check fails
func AssertMinimum ¶
AssertMinimum explodes if a fixed arity check fails
func AssertRanged ¶
AssertRanged explodes if a fixed arity check fails
func DumpString ¶
DumpString takes a Value and dumps out a bunch of info as a string
func HashCode ¶
HashCode returns a hash code for the provided Value. If the Value implements the Hashed interface, it will call us the HashCode() method. Otherwise, it will create a hash code from the stringified form of the Value
func HashString ¶
HashString returns a hash code for the provided string
func MakeSequenceStr ¶
MakeSequenceStr converts a Sequence to a String
func ToQuotedString ¶
ToQuotedString converts Values to string, possibly quoting wrapped Strings
Types ¶
type ArityChecker ¶
ArityChecker is the interface for arity checks
func MakeChecker ¶
func MakeChecker(arity ...int) ArityChecker
MakeChecker produces an arity checker based on its parameters
func MakeFixedChecker ¶
func MakeFixedChecker(fixed int) ArityChecker
MakeFixedChecker generates a fixed arity checker
func MakeMinimumChecker ¶
func MakeMinimumChecker(min int) ArityChecker
MakeMinimumChecker generates a minimum arity checker
func MakeRangedChecker ¶
func MakeRangedChecker(min, max int) ArityChecker
MakeRangedChecker generates a ranged arity checker
type BigInt ¶
BigInt represents a multi-precision integer
func (*BigInt) Cmp ¶
func (l *BigInt) Cmp(r Number) Comparison
Cmp compares this BigInt to another Number
type Bool ¶
type Bool bool
Bool represents the data True or False
type Comparison ¶
type Comparison int
Comparison represents the result of an equality comparison
const ( LessThan Comparison = iota - 1 EqualTo GreaterThan Incomparable )
Comparison results
type Cons ¶
type Cons struct {
// contains filtered or unexported fields
}
Cons cells are the standard implementation of a Pair. Unlike other Pairs (ex: List, Vector), it is not treated as a Sequence
type Counted ¶
type Counted interface {
Count() Integer
}
Counted interfaces allow a Value to return a count of its items
type CountedSequence ¶
CountedSequence is a Sequence that returns a count of its items
type Float ¶
type Float float64
Float represents a 64-bit floating point number
func (Float) Cmp ¶
func (l Float) Cmp(r Number) Comparison
Cmp compares this Float to another Number
type Hashed ¶
type Hashed interface {
HashCode() uint64
}
Hashed can return a hash code for the value
type IndexedSequence ¶
IndexedSequence is a Sequence that has indexed elements
type Integer ¶
type Integer int64
Integer represents a 64-bit integer
func (Integer) Cmp ¶
func (l Integer) Cmp(r Number) Comparison
Cmp compares this Integer to another Number
type Keyword ¶
type Keyword string
Keyword is a Value that represents a Name that resolves to itself
func (Keyword) CheckArity ¶
CheckArity performs a compile-time arity check for the Keyword
type List ¶
type List struct {
// contains filtered or unexported fields
}
A List represents a singly linked List
var ( // Null represents the absence of a Value (the empty List) Null *List )
func (*List) CheckArity ¶
type Mapped ¶
Mapped is the interface for Values that have accessible properties
func DumpMapped ¶
DumpMapped takes a Value and dumps out a bunch of info as a Mapped
type Named ¶
type Named interface {
Name() Local
}
Named is the generic interface for data that are named
type Number ¶
type Number interface { Value Typed Cmp(Number) Comparison Add(Number) Number Sub(Number) Number Mul(Number) Number Div(Number) Number Mod(Number) Number IsNaN() bool IsPosInf() bool IsNegInf() bool }
Number describes a numeric value of some kind
func MustParseFloat ¶
MustParseFloat forcefully parses a string representing a float
func MustParseInteger ¶
MustParseInteger forcefully parse a string representing an integer
func MustParseRatio ¶
MustParseRatio forcefully parses a string representing a ratio
func ParseFloat ¶
ParseFloat attempts to parse a string representing a float
func ParseInteger ¶
ParseInteger attempts to parse a string representing an integer
func ParseRatio ¶
ParseRatio attempts to parse a string representing a ratio
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object maps a set of Values, known as keys, to another set of Values
var (
EmptyObject *Object
)
EmptyObject represents an empty Object
func NewObject ¶
NewObject instantiates a new Object instance. Based on Phil Bagwell's Hashed Array Mapped Trie data structure. More information on HAMT's can be found at http://lampwww.epfl.ch/papers/idealhashtrees.pdf
func ValuesToObject ¶
ValuesToObject interprets a set of Values as an Object
func (*Object) CheckArity ¶
type Procedure ¶
Procedure is a Value that provides a Caller interface
func MakeProcedure ¶
MakeProcedure constructs a Procedure from a func that matches the standard calling signature
type RandomAccess ¶
RandomAccess provides a Sequence that supports random access
type Ratio ¶
Ratio represents a number having a numerator and denominator
func (*Ratio) Cmp ¶
func (l *Ratio) Cmp(r Number) Comparison
Cmp compares this Ratio to another Number
type String ¶
type String string
String is the Sequence-compatible representation of string data
func (String) CheckArity ¶
type Symbol ¶
Symbol is an identifier that can be resolved
func MustParseSymbol ¶
MustParseSymbol parses a qualified Name and produces a Symbol or explodes
func NewGeneratedSymbol ¶
NewGeneratedSymbol creates a generated Symbol
func NewQualifiedSymbol ¶
NewQualifiedSymbol returns a Qualified Symbol for a specific domain
func ParseSymbol ¶
ParseSymbol parses a qualified Name and produces a Symbol
type SymbolGenerator ¶
SymbolGenerator produces instance-unique local symbols
func NewSymbolGenerator ¶
func NewSymbolGenerator() *SymbolGenerator
NewSymbolGenerator creates a new symbol generator. In general, it is safe to use the global generator because it only maintains an incrementer
func (*SymbolGenerator) Local ¶
func (g *SymbolGenerator) Local(name Local) Local
Local returns a newly generated local symbol
func (*SymbolGenerator) Prefix ¶
func (g *SymbolGenerator) Prefix() string
type TypePredicate ¶
type TypePredicate struct {
// contains filtered or unexported fields
}
func MakeTypePredicate ¶
func MakeTypePredicate(t types.Type) *TypePredicate
MakeTypePredicate returns a TypePredicate for the given Type
func TypePredicateOf ¶
func TypePredicateOf(f Value, r ...Value) *TypePredicate
TypePredicateOf returns a TypePredicate for the Types of the given Values. If more than one Value is provided, the Union of their Types will be returned
func (*TypePredicate) Call ¶
func (t *TypePredicate) Call(args ...Value) Value
func (*TypePredicate) CheckArity ¶
func (t *TypePredicate) CheckArity(argc int) error
func (*TypePredicate) Equal ¶
func (t *TypePredicate) Equal(other Value) bool
func (*TypePredicate) Name ¶
func (t *TypePredicate) Name() Local
func (*TypePredicate) Type ¶
func (t *TypePredicate) Type() types.Type
type Vector ¶
type Vector []Value
Vector is a fixed-length array of Values