Skip to content

Latest commit

 

History

History
878 lines (714 loc) · 34 KB

File metadata and controls

878 lines (714 loc) · 34 KB

Goaldi Standard Library

Gregg Townsend and Todd Proebsting
Department of Computer Science
The University of Arizona
goaldi@cs.arizona.edu

This is part of the documentation for The Goaldi Programming Language.


This document lists the procedures and methods present in the Goaldi standard library. It was produced mechanically by extracting source code comments.

For each entry, the header line gives the procedure and argument names followed by a one-line synopsis. A procedure with a suffix of [] in its argument list accepts an arbitrary number of arguments. A more detailed procedure description follows the header line.

Some library procedures such as printf, remove, and regex are just springboards to underlying Go functions. These are indicated by a link on the header line to the Go function. Additional documentation of associated types and methods can be found by following the link.

Extracted descriptions may refer to the Go function and parameter names rather than those of the intermediate Goaldi procedure. In general, if any of these Go functions returns an error, an exception is thrown.

Methods are distinguished from procedures by an inital character and period, as in L.put(…​). The initial character indicates the type of value to which the method applies:

x   any value
t   type value
f   file value
c   channel value
L   list value
S   set value
T   table value


abs(n) — compute absolute value (math.Abs)

Abs returns the absolute value of x.

Special cases are:

Abs(±Inf) = +Inf
Abs(NaN) = NaN
acos(n) — compute arccosine (math.Acos)

Acos returns the arccosine, in radians, of x.

Special case is:

Acos(x) = NaN if x < -1 or x > 1
acosh(n) — compute hyperbolic arccosine (math.Acosh)

Acosh returns the inverse hyperbolic cosine of x.

Special cases are:

Acosh(+Inf) = +Inf
Acosh(x) = NaN if x < 1
Acosh(NaN) = NaN
amean(n[]) — compute arithmetic mean

amean(n,…​) returns the arithmetic mean, or simple average, of its arguments.

asin(n) — compute arcsine (math.Asin)

Asin returns the arcsine, in radians, of x.

Special cases are:

Asin(±0) = ±0
Asin(x) = NaN if x < -1 or x > 1
asinh(n) — compute hyperbolic arcsine (math.Asinh)

Asinh returns the inverse hyperbolic sine of x.

Special cases are:

Asinh(±0) = ±0
Asinh(±Inf) = ±Inf
Asinh(NaN) = NaN
atan(y,x) — compute arctangent of y / x

atan(y, x) returns the arctangent, in radians, of (y/x). The default value of x is 1, so atan(y) returns the arctangent of y. For the handling of special cases see math.Atan2.

atanh(n) — compute hyperbolic arccosine (math.Atanh)

Atanh returns the inverse hyperbolic tangent of x.

Special cases are:

Atanh(1) = +Inf
Atanh(±0) = ±0
Atanh(-1) = -Inf
Atanh(x) = NaN if x < -1 or x > 1
Atanh(NaN) = NaN
buffer(size,c) — interpose buffer before channel

buffer(size, c) returns a channel that interposes a buffer of the given size before the channel c. This is useful in the Goaldi form buffer(size, create e) to provide buffering of the results produced by an asynchronous thread.

c.buffer(size) — interpose channel buffer

c.buffer(size) returns a channel that interposes a buffer of the given size before the channel c.

cbrt(n) — compute cube root (math.Cbrt)

Cbrt returns the cube root of x.

Special cases are:

Cbrt(±0) = ±0
Cbrt(±Inf) = ±Inf
Cbrt(NaN) = NaN
ceil(n) — round up to integer (math.Ceil)

Ceil returns the least integer value greater than or equal to x.

Special cases are:

Ceil(±0) = ±0
Ceil(±Inf) = ±Inf
Ceil(NaN) = NaN
center(s,w,p) — center with padding p to width w

center(s,w,p) centers s in a string of width w, padding with p.

channel(size) — create channel

channel(size) creates and returns a new channel with the given buffer size.

char(n) — return single character for Unicode value

char(n) returns the one-character string corresponding to the Unicode value of n truncated to integer.

t.char() — get abbreviation character

t.char() returns single character used to abbreviate type t.

chdir(dir) — change working directory (os.Chdir)

Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.

chmod(name,mode) — change file mode (os.Chmod)

Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link’s target. If there is an error, it will be of type *PathError.

A different subset of the mode bits are used, depending on the operating system.

On Unix, the mode’s permission bits, ModeSetuid, ModeSetgid, and ModeSticky are used.

On Windows, only the 0o200 bit (owner writable) of mode is used; it controls whether the file’s read-only attribute is set or cleared. The other bits are currently unused. For compatibility with Go 1.12 and earlier, use a non-zero mode. Use mode 0o400 for a read-only file and 0o600 for a readable+writable file.

On Plan 9, the mode’s permission bits, ModeAppend, ModeExclusive, and ModeTemporary are used.

clearenv() — delete all environment variables (os.Clearenv)

Clearenv deletes all environment variables.

f.close() — close file

f.close() closes file f.

c.close() — close channel

c.close() closes the channel c.

command(name,args[]) — build struct to run command (os/exec.Command)

Command returns the Cmd struct to execute the named program with the given arguments.

It sets only the Path and Args in the returned structure.

If name contains no path separators, Command uses LookPath to resolve name to a complete path if possible. Otherwise it uses name directly as Path.

The returned Cmd’s Args field is constructed from the command name followed by the elements of arg, so arg should not include the command name itself. For example, Command("echo", "hello"). Args[0] is always name, not the possibly resolved Path.

On Windows, processes receive the whole command line as a single string and do their own parsing. Command combines and quotes Args into a command line string with an algorithm compatible with applications using CommandLineToArgvW (which is the most common way). Notable exceptions are msiexec.exe and cmd.exe (and thus, all batch files), which have a different unquoting algorithm. In these or other similar cases, you can do the quoting yourself and provide the full command line in SysProcAttr.CmdLine, leaving Args empty.

constructor(name,fields[]) — build a record constructor

constructor(name, field…​) builds a record constructor for creating records with the given type name and field list. There is no requirement or guarantee that record names be distinct.

contains(s,substr) — return 1 if substr is in s (strings.Contains)

Contains reports whether substr is within s.

containsany(s,chars) — return 1 if any char is in s (strings.ContainsAny)

ContainsAny reports whether any Unicode code points in chars are within s.

copy(x) — copy value

copy(x) returns a copy of x if x is a structure, or just x itself if x is a simple value. This is a shallow copy; nested structures are not duplicated.

x.copy() — copy value

copy(x) returns a copy of x if x is a structure, or just x itself if x is a simple value. This is a shallow copy; nested structures are not duplicated.

cos(n) — compute cosine (math.Cos)

Cos returns the cosine of the radian argument x.

Special cases are:

Cos(±Inf) = NaN
Cos(NaN) = NaN
cosh(n) — compute hyperbolic cosine (math.Cosh)

Cosh returns the hyperbolic cosine of x.

Special cases are:

Cosh(±0) = 1
Cosh(±Inf) = +Inf
Cosh(NaN) = NaN
cputime() — return total processor time used

cputime() returns processor usage in seconds, likely a fractional value. The result includes both "user" and "system" time.

date() — return the current date

date() returns the current date in the form "yyyy/mm/dd".

S.delete(x[]) — remove members

S.delete(x…​) removes all of its arguments from set S. It returns S.

T.delete(x[]) — remove entries

T.delete(k…​) deletes the entries with the given keys from the table T. It returns T.

dtor(d) — convert degrees to radians

dtor(d) returns the radian equivalent of the angle d given in degrees.

duration(x) — convert value to a Go Duration struct

duration(x) converts x to an external Go time.Duration value. If x is a string, it is passed directly to time.ParseDuration(). If x is a number, "s" is appended to interpret it as an interval in seconds. If the conversion is unsuccessful, duration() fails.

environ() — get list of environment variables (os.Environ)

Environ returns a copy of strings representing the environment, in the form "key=value".

equalfold(s,t) — return 1 if s==t with case folding (strings.EqualFold)

EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under simple Unicode case-folding, which is a more general form of case-insensitivity.

errresult(e) — return e

errresult(e) returns its argument e. It is suitable for use as a catch handler.

exit(i) — terminate program with exit status

exit(i) terminates execution and returns exit status i, truncated to integer, to the system. A status of 0 signifies normal termination.

exp(n) — return e ^ x (math.Exp)

Exp returns e**x, the base-e exponential of x.

Special cases are:

Exp(+Inf) = +Inf
Exp(NaN) = NaN

Very large values overflow to 0 or +Inf. Very small values underflow to 1.

external(x) — export and re-import

external(x) exports and then re-imports the value x.

x.external() — export and re-import

external(x) exports and then re-imports the value x.

fields(s) — return fields of s delimited by whitespace (strings.Fields)

Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.

file(name,flags) — open a file

file(name,flags) opens a file and returns a file value.

Each character of the optional flags argument selects an option:

"r"   open for reading
"w"   open for writing
"a"   open for appending
"c"   create and open for writing
"n"   no buffering
"f"   fail on error (instead of panicking)

If none of "w", "a", or "c" are specified, then "r" is implied. "w" implies "c" unless "r" is also specified. Buffering is used if "n" is absent and the file is opened exclusively for reading or writing but not both.

In the absence of "f", any error throws an exception.

floor(n) — round down to integer (math.Floor)

Floor returns the greatest integer value less than or equal to x.

Special cases are:

Floor(±0) = ±0
Floor(±Inf) = ±Inf
Floor(NaN) = NaN
f.flush() — flush file

f.flush() flushes output on file f.

fprintf(f,fmt,x[]) — write to file with formatting (fmt.Fprintf)

Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.

gcd(i[]) — find greatest common divisor

gcd(i,…​) truncates its arguments to integer and returns their greatest common divisor. Negative values are allowed. gcd() returns zero if all values are zero.

f.get() — read one line

f.get() consumes and returns next line of text from file f. The trailing linefeed or CRLF is removed from the returned value. f.get() fails at EOF when no more data is available.

c.get() — read from channel

c.get() reads the next value from channel c, or fails if no value is available.

L.get() — remove from front

L.get() removes the first element from list L and returns the element’s value.

getenv(key) — read environment variable (os.Getenv)

Getenv retrieves the value of the environment variable named by the key. It returns the value, which will be empty if the variable is not present. To distinguish between an empty value and an unset value, use LookupEnv.

getpid() — get process ID (os.Getpid)

Getpid returns the process id of the caller.

getppid() — get parent process ID (os.Getppid)

Getppid returns the process id of the caller’s parent.

getwd() — get working directory (os.Getwd)

Getwd returns an absolute path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), Getwd may return any one of them.

On Unix platforms, if the environment variable PWD provides an absolute name, and it is a name of the current directory, it is returned.

gmean(n[]) — compute geometric mean

gmean(n,…​) returns the geometric mean of its arguments, which must all be strictly positive.

hmean(n[]) — compute harmonic mean

hmean(n,…​) returns the harmonic mean of its arguments, which must all be strictly positive.

hostname() — get host machine name (os.Hostname)

Hostname returns the host name reported by the kernel.

hypot(x,y) — return sqrt of x^2 + y^2 (math.Hypot)

Hypot returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.

Special cases are:

Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q) = NaN
Hypot(p, NaN) = NaN
iand(i,j) — compute bitwise AND

iand(i, j) returns the bitwise AND of the values i and j truncated to integer.

iclear(i,j) — compute bitwise clear of i by j

iclear(i, j) returns the value of i cleared of those bits set in j, after truncating both arguments to integer.

icom(i) — compute bitwise complement

icom(i) truncates i to integer and returns its bitwise complement.

image(x) — return detailed string image

image(x) returns a string image of x. This is the same conversion applied by sprintf("%#v",x) and is typically more verbose and detailed than the result of string(x).

x.image() — return detailed string image

image(x) returns a string image of x. This is the same conversion applied by sprintf("%#v",x) and is typically more verbose and detailed than the result of string(x).

x.instanceof(t) — check type relationship

x.instanceof(t) returns x if x is an instance of type t; otherwise the call fails.

integer(n) — truncate to integer (math.Trunc)

Trunc returns the integer value of x.

Special cases are:

Trunc(±0) = ±0
Trunc(±Inf) = ±Inf
Trunc(NaN) = NaN
ior(i,j) — compute bitwise OR

ior(i, j) returns the bitwise OR of the values i and j truncated to integer.

ishift(i,j) — compute bitwise shift of i by j

ishift(i, j) shifts i by j bits and returns the result. If j > 0, the shift is to the left with zero fill. If j < 0, the shift is to the right with sign extension. The arguments are both truncated to integer before operating.

ixor(i,j) — compute bitwise exclusive OR

ixor(i, j) returns the bitwise exclusive OR of the values i and j truncated to integer.

left(s,w,p) — left-justify with padding p to width w

left(s,w,p) left-justifies s in a string of width w, padding with p.

list(size,x) — create list of copies of x

list(size, x) builds and returns a new list of the given size with each element initialized to a copy of x.

log(n,b) — compute logarithm to base b

log(n, b) returns the logarithm of n to base b. The default value of b is %e (2.7183…​), so log(n) returns the natural logarithm of n.

map(s,from,into) — map characters

map(s,from,into) produces a new string that result from mapping the individual characters of a source string. Each character of s that appears in the "from" string is replaced by the corresponding character of the "into" string. If there is no corresponding character, because "into" is shorter, then the character from s is discarded.

max(n[]) — find maximum value

max(n, …​) returns the largest of its arguments.

S.member(x) — test membership

S.member(x) returns x if x is a member of set S; otherwise it fails.

T.member(x) — test membership

T.member(k) returns k if k is an existing key in table T; otherwise it fails.

methodvalue(x) — succeed if methodvalue

methodvalue(x) returns x if x is a method value, and fails otherwise.

min(n[]) — find minimum value

min(n, …​) returns the smallest of its arguments.

mkdir(name,perm) — create directory (os.Mkdir)

Mkdir creates a new directory with the specified name and permission bits (before umask). If there is an error, it will be of type *PathError.

mkdirall(path,perm) — create directory tree (os.MkdirAll)

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.

t.name() — get type name

t.name() returns the name of type t.

nilresult(e) — return nil

nilresult(e) returns nil, ignoring e. It is suitable for use as a catch handler.

niltype() — return nil value

niltype() always returns the sole instance of the nil value. niltype is the name of the result of nil.type().

noresult(e) — fail immediately

noresult(e) fails immediately, ignoring e. It is suitable for use as a catch handler.

now() — return the current instant as a Go Time struct

now() returns the current time as an external Go time.Time value, which can then be formatted or otherwise manipulated by calling tval.Format() or other associated methods.

number(x) — convert to number

number(x) returns its argument converted to number, or fails if it cannot be converted due to its form or datatype. For string (or stringable) arguments, number() trims leading and trailing spaces and then accepts standard Go decimal forms (fixed and floating) or Goaldi radix forms (101010b, 52o, 2Ax, 23r1J).

ord(s) — return Unicode ordinal of single character

ord(s) returns the Unicode value corresponding to the one-character string s.

L.pop() — remove from front

L.pop() removes the first element from list L and returns the element’s value.

print(x[]) — write values with spacing

print(x,…​) writes its arguments to %stdout, separated by spaces.

f.print(x[]) — write values with spacing

f.print(x,…​) writes its arguments to file f, separated by spaces.

printf(fmt,x[]) — write with formatting (fmt.Printf)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

println(x[]) — write line of values

println(x,…​) writes its arguments to %stdout, separated by spaces and terminated by a newline character.

f.println(x[]) — write line of values

f.println(x,…​) writes its arguments to file f, separated by spaces and terminated by a newline character.

proctype(x) — succeed if procedure

proctype(x) returns x if x is a procedure, and fails otherwise. proctype is the name of the result of main.type().

L.pull() — remove from end

L.pull() removes the final element from list L and returns the element’s value.

L.push(x[]) — add to front

L.push(x…​) adds its arguments, in order, to the beginning of list L. The last argument thus ends up as the first element of L.

f.put(x[]) — write values as lines

f.put(x,…​) writes its arguments to file f, each followed by a newline. This treats a file as as a container of text values separated by newlines, which is consistent with the interpretation used by f.get().

c.put(x) — send to channel

c.put(e…​) writes its argument values, in order, to channel c.

L.put(x[]) — add to end

L.put(x…​) adds its arguments, in order, to the end of list L. The last argument becomes the final element of L.

S.put(x[]) — add members

S.put(x…​) adds all its arguments to set S. It returns the set S.

qmean(n[]) — compute quadratic mean

qmean(n,…​) returns the quadratic mean, or root mean square, of its arguments.

quote(s) — add quotation marks and escapes to s (strconv.Quote)

Quote returns a double-quoted Go string literal representing s. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for control characters and non-printable characters as defined by IsPrint.

randgen(seed) — create independent random sequence

randgen(i) returns a new random generator seeded by i. The returned external value is a Go math.rand/Rand object whose methods may be called from Goaldi to produce random values.

randomize() — irreproducibly seed random generation

randomize() seeds the random number generator with an irreproducible value obtained from /dev/urandom.

read(f) — read one line from a file

read(f) consumes and returns next line of text from file f. The trailing linefeed or CRLF is removed from the returned value. read() fails at EOF when no more data is available.

f.read() — read one line

f.read() consumes and returns next line of text from file f. The trailing linefeed or CRLF is removed from the returned value. f.read() fails at EOF when no more data is available.

f.readb(size) — read binary bytes

f.readb(n) reads up to n bytes into individual characters without attempting any UTF-8 decoding. This is useful for reading binary files. f.readb() fails at EOF when no more data is available.

regex(expr) — compile Go regular expression (regexp.Compile)

Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against text.

When matching against text, the regexp returns a match that begins as early as possible in the input (leftmost), and among those it chooses the one that a backtracking search would have found first. This so-called leftmost-first matching is the same semantics that Perl, Python, and other implementations use, although this package implements it without the expense of backtracking. For POSIX leftmost-longest matching, see CompilePOSIX.

regexp(expr) — compile POSIX regular expression (regexp.CompilePOSIX)

CompilePOSIX is like Compile but restricts the regular expression to POSIX ERE (egrep) syntax and changes the match semantics to leftmost-longest.

That is, when matching against text, the regexp returns a match that begins as early as possible in the input (leftmost), and among those it chooses a match that is as long as possible. This so-called leftmost-longest matching is the same semantics that early regular expression implementations used and that POSIX specifies.

However, there can be multiple leftmost-longest matches, with different submatch choices, and here this package diverges from POSIX. Among the possible leftmost-longest matches, this package chooses the one that a backtracking search would have found first, while POSIX specifies that the match be chosen to maximize the length of the first subexpression, then the second, and so on from left to right. The POSIX rule is computationally prohibitive and not even well-defined. See https://swtch.com/~rsc/regexp/regexp2.html#posix for details.

remove(name) — delete file (os.Remove)

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

rename(old,new) — change file name (os.Rename)

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. If newpath already exists and is a directory, Rename returns an error. OS-specific restrictions may apply when oldpath and newpath are in different directories. Even within the same directory, on non-Unix platforms Rename is not an atomic operation. If there is an error, it will be of type *LinkError.

repl(s,count) — concatenate copies of s (strings.Repeat)

Repeat returns a new string consisting of count copies of the string s.

It panics if count is negative or if the result of (len(s) * count) overflows.

replace(s,old,new) — return s with new replacing old (strings.Replace)

Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, there is no limit on the number of replacements.

reverse(s) — return mirror image of string

reverse(s) returns the end-for-end reversal of the string s.

right(s,w,p) — right-justify with padding p to width w

right(s,w,p) right-justifies s in a string of width w, padding with p.

rtod(r) — convert radians to degrees

rtod(r) returns the degree equivalent of the angle r given in radians.

seed(n) — set random number seed (math/rand.Seed)

Seed uses the provided seed value to initialize the default Source to a deterministic state. Seed values that have the same remainder when divided by 2³¹-1 generate the same pseudo-random sequence. Seed, unlike the Rand.Seed method, is safe for concurrent use.

If Seed is not called, the generator is seeded randomly at program startup.

Prior to Go 1.20, the generator was seeded like Seed(1) at program startup. To force the old behavior, call Seed(1) at program startup. Alternately, set GODEBUG=randautoseed=0 in the environment before making any calls to functions in this package.

Deprecated: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator.

As of Go 1.24 Seed is a no-op. To restore the previous behavior set GODEBUG=randseednop=0.

f.seek(n) — set file position

f.seek(n) sets the position for the next read or write on file f. File positions are measured in bytes, not characters, counting the first byte as

  1. A value of 0 seeks to end of file, and a negative value is an offset from the end.

seq(n,incr) — produce n to infinity

seq(n,incr) generates an endless sequence of values beginning at n with increments of incr.

set(L) — create a new set from list L

set(L) creates a set initialized by the values of list L.

setenv(key,value) — set environment variable (os.Setenv)

Setenv sets the value of the environment variable named by the key. It returns an error, if any.

L.shuffle() — return randomized copy

L.shuffle() returns a copy of list L in which the elements have been randomly reordered.

sin(n) — compute sine (math.Sin)

Sin returns the sine of the radian argument x.

Special cases are:

Sin(±0) = ±0
Sin(±Inf) = NaN
Sin(NaN) = NaN
sinh(n) — compute hyperbolic sine (math.Sinh)

Sinh returns the hyperbolic sine of x.

Special cases are:

Sinh(±0) = ±0
Sinh(±Inf) = ±Inf
Sinh(NaN) = NaN
sleep(n) — pause execution momentarily

sleep(n) delays execution for n seconds, which may be a fractional value. If n is nil, sleep() blocks indefinitely.

L.sort(i) — return sorted copy

L.sort(i) returns a copy of list L in which the elements have been sorted. Values are ordered first by type, then within types by their values. Among lists and among records of the same type, ordering is based on field i. Lists with no element i are sorted ahead of lists that have one. The value i defaults to 1 and must be strictly positive.

S.sort(i) — produce sorted list

S.sort(i) returns a sorted list of the members of set S. This is equivalent to [:!S:].sort(i).

T.sort(i) — produce sorted list

T.sort(i) returns a sorted list of elemtype(key,value) records holding the contents of table T. Sorting is by key if i=1 and by value if i=2. T.sort(i) is equivalent to [:!T:].sort(i).

split(s,sep) — return fields delimited by sep (strings.Split)

Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.

If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.

If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.

It is equivalent to SplitN with a count of -1.

To split around the first instance of a separator, see Cut.

sprintf(fmt,x[]) — make string by formatting values (fmt.Sprintf)

Sprintf formats according to a format specifier and returns the resulting string.

sqrt(n) — compute square root (math.Sqrt)

Sqrt returns the square root of x.

Special cases are:

Sqrt(+Inf) = +Inf
Sqrt(±0) = ±0
Sqrt(x < 0) = NaN
Sqrt(NaN) = NaN
stop(x[]) — write values and abort program

stop(x,…​) writes its arguments to %stderr and terminates execution with an exit code of 1 (indicating an error).

string(x) — render as string

string(x) returns a string representation of x. The result is identical to the value used by write(x) or sprintf("%v",x).

x.string() — render value as string

string(x) returns a string representation of x. The result is identical to the value used by write(x) or sprintf("%v",x).

table(x) — create a table with default value x

table(x) creates a new, empty table having x as the default value.

tan(n) — compute tangent (math.Tan)

Tan returns the tangent of the radian argument x.

Special cases are:

Tan(±0) = ±0
Tan(±Inf) = NaN
Tan(NaN) = NaN
tanh(n) — compute hyperbolic tangent (math.Tanh)

Tanh returns the hyperbolic tangent of x.

Special cases are:

Tanh(±0) = ±0
Tanh(±Inf) = ±1
Tanh(NaN) = NaN
throw(e,x[]) — terminate with error and offending values

throw(e, x…​) raises an exception with error value e and zero or more offending values. If not caught, the exception terminates execution.

If e is a number or string, a Goaldi exception is created using e. Otherwise, the value e is thrown directly, without interpretation.

time() — return the current time

time() returns the current time of day in the form "hh:mm:ss".

tolower(s) — convert to lower case (strings.ToLower)

ToLower returns s with all Unicode letters mapped to their lower case.

toupper(s) — convert to upper case (strings.ToUpper)

ToUpper returns s with all Unicode letters mapped to their upper case.

trim(s,cutset) — remove leading and trailing characters (strings.Trim)

Trim returns a slice of the string s with all leading and trailing Unicode code points contained in cutset removed.

truncate(name,size) — change file size (os.Truncate)

Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link’s target. If there is an error, it will be of type *PathError.

tuple(id:e…​) — create anonymous record

tuple(id:e, …​) creates an anonymous record value. Each argument must be named. Each distinct identifier list defines a new type, all of which have the name "tuple".

type(x) — return type of value

type(x) returns the value of type "type" that represents the type of x.

x.type() — return type of value

type(x) returns the value of type "type" that represents the type of x.

f.unbuffer() — stop file buffering

f.unbuffer() removes any buffering from file f. Any buffered output is flushed; any buffered input is lost.

unquote(s) — remove delimiters and escapes from s

unquote(s) removes delimiters and escapes from a quoted string. The argument s must begin and end with explicit "double quotes" or `backticks`. unquote() fails if s is not properly quoted or if it contains an invalid (by Go rules) escape sequence.

f.where() — report current file position

f.where() reports the current position of file f. File positions are measured in bytes, counting the first byte as 1.

write(x[]) — write values and newline

write(x,…​) writes its arguments to %stdout followed by a newline.

f.write(x[]) — write values and newline

f.write(x,…​) writes its arguments to file f followed by a single newline.

f.writeb(s) — write binary bytes

f.writeb(s) writes the string s to file f without any UTF-8 encoding. Instead, the low 8 bits of each character are written as a single byte, ignoring all other bits. This is useful for writing binary files.

writes(x[]) — write values

writes(x,…​) write its arguments to %stdout with no following newline.

f.writes(x[]) — write values

f.writes(x,…​) write its arguments to file f with no following newline.