wdte: github.com/DeedleFake/wdte/std Index | Files | Directories

package std

import "github.com/DeedleFake/wdte/std"

Package std provides a number of basic WDTE functions.

The functions provided by this package are slightly different from those in many of the standard library's packages in that they are intended to be directly inserted into the top-level scope, rather than imported. They provide basic functionality, such as addition and subtraction, as well as some more language-specific functionality, such as the ability to check the type of a value.

Index

Package Files

doc.go import.go std.go

Constants

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

var (
    // Import provides a simple importer that imports registered
    // modules.
    Import = wdte.ImportFunc(stdImporter)
)
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),
    "set":     wdte.GoFunc(Set),
    "reflect": wdte.GoFunc(Reflect),
})

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.

func And Uses

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 Uses

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 Uses

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.

func Div Uses

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 Uses

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 Uses

func F() wdte.Frame

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

func Greater Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Reflect Uses

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

Reflect is a WDTE function with the following signature:

reflect v type
(reflect type) v

It provides a simple wrapper around wdte.Reflect, checking underlying type compatability.

func Register Uses

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

Register registers a module for importing by Import.

func Set Uses

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

Set is a WDTE function with the following signatures:

set con key val
(set val) con key
(set key val) con

Set uses con's implementation of Setter to produce a new value from con with a key-val mapping applied to it. For example,

set [1; 2; 3] 1 5

returns a new Array containing [1; 5; 3].

func Times Uses

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.

Directories

PathSynopsis
allPackage all is a convenience package that imports the entire standard library, thus registering it with std.Import.
arraysPackage arrays contains functions for manipulating arrays.
ioPackage io contains WDTE functions for dealing with files and other types of data streams.
io/filePackage file provides functions for dealing with files.
mathPackage math contains wdte.Funcs for performing mathematical operations.
randPackage rand provides functions for generating and dealing with random numbers.
streamPackage stream provides WDTE functions for manipulating streams of data.
stringsPackage strings contains functions for dealing with strings.

Package std imports 4 packages (graph) and is imported by 7 packages. Updated 2019-07-21. Refresh now. Tools for package owners.