Skip to main content

Module stdlib

Module stdlib 

Source
Expand description

Defines some basic macros for regular use.

Structs§

Add
Adds all arguments, returning their sum.
And
Takes the boolean and of all inputs.
Argslice
Gets a slice of the given arguments.
Assert
Raises an error with a specified message if the first argument is not truthy.
BSlice
Slices the given string by a start, stop, and optional step, based on bytes.
Base64Decode
Decodes some given Base64.
Base64Encode
Encodes some given data to Base64.
Bin
Converts its first argument to binary.
BitARShift
Calculates the arithmetic right bit shift of the given value. All values will be coerced to integers.
BitAnd
Calculates the binary AND of the given values. All values will be coerced to integers.
BitLRShift
Calculates the logical right bit shift of the given value. All values will be coerced to integers.
BitLShift
Calculates the left bit shift of the given value. All values will be coerced to integers.
BitNot
Calculates the binary NOT of the given values individually. All values will be coerced to integers.
BitOr
Calculates the binary OR of the given values. All values will be coerced to integers.
BitXor
Calculates the binary XOR of the given values. All values will be coerced to integers.
Byte
Returns a single byte from a hexadecimal value.
ByteGet
Gets a single byte of a variable as a hexadecimal value.
ByteLength
Gets the byte length of a string.
ByteSet
Sets a single byte of a variable to a hexadecimal value.
ByteSplice
Splices a string of hexadecimal bytes into a variable.
Char
Returns a single UTF-8 character from a given integer value.
Compare
Compares a number to another. Returns 1 on Ordering::Greater, 0 on Ordering::Equal, -1 on Ordering::Less, and nan if an order cannot be determined.
Concat
Joins each argument with an empty string.
Cosine
Gets the cosine of a number.
Count
Finds the amount of occurrences of a string within another, optionally between a given range.
Discard
Discards all arguments, returning nothing. Will still run any macros within its arguments - this one isn’t “special”.
Divide
Divides the first argument by the second.
Drop
Drops a variable from the variable registry.
Ease
Interpolates a value using a given time and easing method.
Equal
Checks if two strings are equal.
Error
Raises an error with a specified message.
Expr
Evaluates an RPN expression. See [expr.def].
ExprCall
Evaluates a stored RPN expression.
ExprDef
Parses a RPN expression and saves it to a function variable.
ExprForward
Sets up an RPN expression with a given amount of arguments to be defined later. Useful for recursive calls.
Find
Finds the first occurrence of a string within another, optionally between a given range. Returns -1 if not found.
For
Repeats a string for each element in a list, replacing one pattern in each with the list index and another with the value, optionally separated by a separator. The string, patterns, and list all must be valid UTF-8.
Get
Loads a variable from the variable registry, or sets it to and returns the second argument if it doesn’t exist.
Greater
Checks if one number is greater than another.
Hash
Hashes the given value.
Hex
Converts its first argument to hexadecimal.
If
Chooses between a set of return values from a chain of booleans.
Imaginary
Gets the imaginary component of a number.
Input
Checks if the given input value to a text macro was used.
Int
Converts the first argument to an integer.
IsMacro
Checks if macros exist within the execution context.
IsNumber
Checks if a value is a number.
IsStored
Checks if a variable exists.
Join
Joins each argument.
Length
Gets the character length of a UTF-8 string.
Less
Checks if one number is less than another.
Load
Loads a variable from the variable registry.
Log
Takes the logarithm of the first argument with the second as a base.
Lower
Converts its first argument to ASCII lowercase.
Modulus
Takes the modulus of the first argument with the second.
Multiply
Multiplies all arguments, returning their product.
Not
Logically negates a boolean.
NumEqual
Checks if one number is equal than another.
Oct
Converts its first argument to octal.
Or
Takes the boolean or of all inputs.
Ord
Gets the Unicode codepoint of a given one-character string.
Pow
Raises the first argument to the second.
Random
Creates a random value on the range [0, 1).
Real
Gets the real component of a number.
Repeat
Repeats a string a given amount of times.
Replace
Replaces a string within another string, using regex matching. All arguments must be valid UTF-8.
SReplace
Replaces a string within another string, using the Aho-Corasick algorithm.
Sequence
Repeats a string a set amount times, replacing a pattern in each with a number on a range, optionally separated by a separator. The pattern, repeated string, and separator all must be valid UTF-8.
Shuffle
Shuffles the given arguments.
Sine
Gets the sine of a number.
Slice
Slices the given string by a start, stop, and optional step, based on UTF-8 characters. The string must be valid UTF-8.
Split
Splits a string into a list by a delimiter, and then indexes into that list.
Step
Gets the current execution step number.
Store
Stores a variable in the variable registry.
Subtract
Subtracts the second argument from the first.
Tangent
Gets the tangent of a number.
Title
Converts its first argument to ASCII title case.
ToBoolean
Converts a value into a boolean.
ToFloatDeprecated
Returns its first argument. Legacy alias for compatiblity reasons.
UReplace
Replaces a string within another string, using regex matching. Unescapes needles and replacement patterns first. All arguments must be valid UTF-8.
Unescape
Unescapes the argument.
UnixTime
Gets the amount of seconds since January 1, 1970, 00:00 GMT.
Upper
Converts its first argument to ASCII uppercase.
Utf8
Converts the given bytestring to UTF-8 lossily, replacing errors with U+FFFD.
ZlibCompress
Compresses a given string using zlib, returning the compressed data Base64-encoded.
ZlibDecompress
Decompresses a given string using zlib, first decoding it from Base64.