std

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// True is a WDTE function with the following signature:
	//
	//    true
	//
	// As you can probably guess, it returns a boolean true.
	True wdte.Bool = true

	// False is a WDTE function with the following signature:
	//
	//    false
	//
	// Returns a boolean false. This is rarely necessary as most
	// built-in functionality considers any value other than a boolean
	// true to be false, but it's provided for completeness.
	False wdte.Bool = false
)

Variables

View Source
var (
	// Import provides a simple importer that imports registered
	// modules.
	Import = wdte.ImportFunc(stdImporter)
)
View Source
var Scope = wdte.S().Map(map[wdte.ID]wdte.Func{
	"+": wdte.GoFunc(Plus),
	"-": wdte.GoFunc(Minus),
	"*": wdte.GoFunc(Times),
	"/": wdte.GoFunc(Div),
	"%": wdte.GoFunc(Mod),

	"==":    wdte.GoFunc(Equals),
	"<":     wdte.GoFunc(Less),
	">":     wdte.GoFunc(Greater),
	"<=":    wdte.GoFunc(LessEqual),
	">=":    wdte.GoFunc(GreaterEqual),
	"true":  True,
	"false": False,
	"&&":    wdte.GoFunc(And),
	"||":    wdte.GoFunc(Or),
	"!":     wdte.GoFunc(Not),

	"len":     wdte.GoFunc(Len),
	"at":      wdte.GoFunc(At),
	"collect": wdte.GoFunc(Collect),
	"known":   wdte.GoFunc(Known),
	"sub":     wdte.GoFunc(Sub),
})

Scope is a scope containing the functions in this package.

This scope is primarily useful for bootstrapping an environment for running scripts in. To use it, simply pass a frame containing it or a subscope of it to a function call. In many cases, a client can simply call F to obtain such a frame.

Functions

func And

func And(frame wdte.Frame, args ...wdte.Func) wdte.Func

And is a WDTE function with the following signature:

&& ...

Returns true if all of its arguments are true.

func At

func At(frame wdte.Frame, args ...wdte.Func) wdte.Func

At is a WDTE function with the following signatures:

at a i
(at i) a

Returns the ith index of a. a is assumed to implement wdte.Atter.

func Collect

func Collect(frame wdte.Frame, args ...wdte.Func) wdte.Func

Collect is a WDTE function with the following signature:

collect compound

Collect takes a compound as its argument and returns the scope collected from executing that compound. The argument must be a compound literal or the function will fail. Assigning a compound to an ID and then passing that ID will not work.

It surrounds the returned scope with a bound called "collect".

func Div

func Div(frame wdte.Frame, args ...wdte.Func) wdte.Func

Div is a WDTE function with the following signatures:

/ a b
(/ b) a

Returns a divided by b.

func Equals

func Equals(frame wdte.Frame, args ...wdte.Func) wdte.Func

Equals is a WDTE function with the following signatures:

== a b
(== b) a

Returns true if a equals b. If a implements wdte.Comparer, the equality check is done using that implementation. If a does not but b does, b's implementation is used. If neither does, a direct Go equality check is used.

func F

func F() wdte.Frame

F returns a top-level frame that has S as its scope.

func Greater

func Greater(frame wdte.Frame, args ...wdte.Func) wdte.Func

Greater is a WDTE function with the following signatures:

> a b
(> b) a

Returns true if a is greater than b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.

func GreaterEqual

func GreaterEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func

GreaterEqual is a WDTE function with the following signatures:

>= a b
(>= b) a

Returns true if a is greater than or equal to b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.

func Known added in v0.2.2

func Known(frame wdte.Frame, args ...wdte.Func) wdte.Func

Known is a WDTE function with the following signature:

known scope

Returns an array containing known identifiers in the given scope sorted alphabetically.

func Len

func Len(frame wdte.Frame, args ...wdte.Func) wdte.Func

Len is a WDTE function with the following signature:

len a

Returns the length of a if a implements wdte.Lenner, or false if it doesn't.

func Less

func Less(frame wdte.Frame, args ...wdte.Func) wdte.Func

Less is a WDTE function with the following signatures:

< a b
(< b) a

Returns true if a is less than b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.

func LessEqual

func LessEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func

LessEqual is a WDTE function with the following signatures:

<= a b
(<= b) a

Returns true if a is less than or equal to b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.

func Minus

func Minus(frame wdte.Frame, args ...wdte.Func) wdte.Func

Minus is a WDTE with the following signatures:

  • a b (- b) a

Returns a minus b.

func Mod

func Mod(frame wdte.Frame, args ...wdte.Func) wdte.Func

Mod is a WDTE function with the following signatures:

% a b
(% b) a

Returns a mod b.

func Not

func Not(frame wdte.Frame, args ...wdte.Func) wdte.Func

Not is a WDTE function with the following signature:

! a

Returns true if a is not true or false if a is not true.

func Or

func Or(frame wdte.Frame, args ...wdte.Func) wdte.Func

Or is a WDTE function with the following signature:

|| ...

Returns true if any of its arguments are true.

func Plus

func Plus(frame wdte.Frame, args ...wdte.Func) wdte.Func

Plus is a WDTE function with the following signatures:

  • a ... (+ a) ...

Returns the sum of a and the rest of its arguments.

func Register

func Register(name string, module *wdte.Scope)

Register registers a module for importing by Import.

func Sub

func Sub(frame wdte.Frame, args ...wdte.Func) wdte.Func

Sub is a WDTE function with the following signatures:

sub scope id val
(sub val) scope id
(sub id val) scope

Sub returns a subscope of scope with the value val bound to the ID id. It puts a "collect" lower bound on the scope but does not add any upper bounds.

func Times

func Times(frame wdte.Frame, args ...wdte.Func) wdte.Func

Times is a WDTE function with the following signatures:

  • a ... (* a) ...

Returns the product of a and its other arguments.

Types

This section is empty.

Directories

Path Synopsis
Package all is a convience package that imports the entire standard library, thus registering it with std.Import.
Package all is a convience package that imports the entire standard library, thus registering it with std.Import.
Package arrays contains functions for manipulating arrays.
Package arrays contains functions for manipulating arrays.
io
Package io contains WDTE functions for dealing with files and other types of data streams.
Package io contains WDTE functions for dealing with files and other types of data streams.
file
Package file provides functions for dealing with files.
Package file provides functions for dealing with files.
Package math contains wdte.Funcs for performing mathematical operations.
Package math contains wdte.Funcs for performing mathematical operations.
Package stream provides WDTE functions for manipulating streams of data.
Package stream provides WDTE functions for manipulating streams of data.
Package strings contains functions for dealing with strings.
Package strings contains functions for dealing with strings.

Jump to

Keyboard shortcuts

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