core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NS = map[string]MalType{
	"=":       Call2b(Equal_Q),
	"throw":   Call1e(throw),
	"nil?":    Call1b(Nil_Q),
	"true?":   Call1b(True_Q),
	"false?":  Call1b(False_Q),
	"symbol":  Call1e(func(a []MalType) (MalType, error) { return Symbol{Val: a[0].(string)}, nil }),
	"symbol?": Call1b(Symbol_Q),
	"string?": Call1e(func(a []MalType) (MalType, error) { return (String_Q(a[0]) && !Keyword_Q(a[0])), nil }),
	"keyword": Call1e(func(a []MalType) (MalType, error) {
		if Keyword_Q(a[0]) {
			return a[0], nil
		} else {
			return NewKeyword(a[0].(string))
		}
	}),
	"keyword?":    Call1b(Keyword_Q),
	"number?":     Call1b(Number_Q),
	"fn?":         Call1e(fn_q),
	"macro?":      Call1e(func(a []MalType) (MalType, error) { return MalFunc_Q(a[0]) && a[0].(MalFunc).GetMacro(), nil }),
	"pr-str":      CallNe(pr_str),
	"str":         CallNe(str),
	"prn":         CallNe(prn),
	"println":     CallNe(println),
	"read-string": Call1e(func(a []MalType) (MalType, error) { return reader.Read_str(a[0].(string), nil) }),
	"<":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) < a[1].(int), nil }),
	"<=":          Call2e(func(a []MalType) (MalType, error) { return a[0].(int) <= a[1].(int), nil }),
	">":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) > a[1].(int), nil }),
	">=":          Call2e(func(a []MalType) (MalType, error) { return a[0].(int) >= a[1].(int), nil }),
	"+":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) + a[1].(int), nil }),
	"-":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) - a[1].(int), nil }),
	"*":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) * a[1].(int), nil }),
	"/":           Call2e(func(a []MalType) (MalType, error) { return a[0].(int) / a[1].(int), nil }),
	"time-ms":     Call0e(time_ms),
	"time-ns":     Call0e(time_ns),
	"list":        CallNe(func(a []MalType) (MalType, error) { return List{Val: a}, nil }),
	"list?":       Call1b(List_Q),
	"vector":      CallNe(func(a []MalType) (MalType, error) { return Vector{Val: a}, nil }),
	"vector?":     Call1b(Vector_Q),
	"hash-map":    CallNe(func(a []MalType) (MalType, error) { return NewHashMap(List{Val: a}) }),
	"map?":        Call1b(HashMap_Q),
	"assoc":       CallNe(assoc),
	"dissoc":      CallNe(dissoc),
	"get":         Call2e(get),
	"contains?":   Call2e(func(a []MalType) (MalType, error) { return contains_Q(a[0], a[1]) }),
	"keys":        Call1e(keys),
	"vals":        Call1e(vals),
	"sequential?": Call1b(Sequential_Q),
	"cons":        Call2e(cons),
	"concat":      CallNe(concat),
	"vec":         Call1e(vec),
	"nth":         Call2e(nth),
	"first":       Call1e(first),
	"rest":        Call1e(rest),
	"empty?":      Call1e(empty_Q),
	"count":       Call1e(count),
	"apply":       CallNeC(apply),
	"map":         Call2eC(do_map),
	"conj":        CallNe(conj),
	"seq":         Call1e(seq),
	"with-meta":   Call2e(with_meta),
	"meta":        Call1e(meta),
	"atom":        Call1e(func(a []MalType) (MalType, error) { return &Atom{Val: a[0]}, nil }),
	"atom?":       Call1b(Atom_Q),
	"deref":       Call1e(deref),
	"reset!":      Call2e(reset_BANG),
	"swap!":       CallNeC(swap_BANG),

	"range":      Call2e(rangeVector),
	"sleep":      Call1eC(sleep),
	"base64":     Call1e(base64encode),
	"unbase64":   Call1e(base64decode),
	"str2binary": Call1e(str2binary),
	"binary2str": Call1e(binary2str),
	"jsondecode": Call1e(jsonDecode),
	"jsonencode": Call1e(jsonEncode),
	"merge":      Call2e(mergeHashMap),
	"assert":     CallNe(assert),
}

core namespace

View Source
var NSInput = map[string]MalType{
	"slurp":    Call1e(slurp),
	"readline": Call1e(readLine),
}

Functions

func Call0e

func Call0e(f func([]MalType) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

callXX functions check the number of arguments

func Call0eC

func Call0eC(f func([]MalType, *context.Context) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func Call1b

func Call1b(f func(MalType) bool) func([]MalType, *context.Context) (MalType, error)

func Call1e

func Call1e(f func([]MalType) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func Call1eC

func Call1eC(f func([]MalType, *context.Context) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func Call2b

func Call2b(f func(MalType, MalType) bool) func([]MalType, *context.Context) (MalType, error)

func Call2e

func Call2e(f func([]MalType) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func Call2eC

func Call2eC(f func([]MalType, *context.Context) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func CallNe

func CallNe(f func([]MalType) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

func CallNeC

func CallNeC(f func([]MalType, *context.Context) (MalType, error)) func([]MalType, *context.Context) (MalType, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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