Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ranty Standard Library

The Ranty Standard Library contains the builtin functions and constants loaded into a fresh Ranty context.

Builtins are loaded into a fresh context as predeclared global values. Functions such as len, keys, and upper are constant globals, so you can call them immediately with ordinary bracket syntax like [len: value], but you cannot reassign them in place.

Categories

The detailed reference pages below remain the canonical prose documentation for each category. The generated inventory that follows is rebuilt from the current export surface on every docs build and is used by the audit checks to catch drift.

Stdlib Inventory

SymbolCategoryUsageSummaryCanonical Location
BUILD_VERSIONConstantsBUILD_VERSIONThe build version of the Ranty library being used.stdlib/constants.md#build_version
EPSILONConstantsEPSILONThe smallest possible float value greater than zero.stdlib/constants.md#epsilon
INFINITYConstantsINFINITYThe floating-point special value for positive infinity.stdlib/constants.md#infinity
MAX_FLOATConstantsMAX_FLOATThe largest representable finite value of the float type.stdlib/constants.md#max_float
MAX_INTConstantsMAX_INTThe largest representable value of the int type.stdlib/constants.md#max_int
MIN_FLOATConstantsMIN_FLOATThe smallest representable finite value of the float type.stdlib/constants.md#min_float
MIN_INTConstantsMIN_INTThe smallest representable value of the int type.stdlib/constants.md#min_int
NANConstantsNANThe floating-point special value for NaN (Not a Number).stdlib/constants.md#nan
NEG_INFINITYConstantsNEG_INFINITYThe floating-point special value for negative infinity.stdlib/constants.md#neg_infinity
RANTY_VERSIONConstantsRANTY_VERSIONThe version of the Ranty language currently being used.stdlib/constants.md#ranty_version
absMath[abs: num]Prints the absolute value of num.stdlib/math.md#abs
acosMath[acos: x]Calculates the arccosine (in radians) of x.stdlib/math.md#acos
addMath[add: lhs; rhs]Adds two values and prints the sum.stdlib/math.md#add
alphaGenerators[alpha: count ? 1]Prints a uniformly random lowercase alphabetic string.stdlib/generators.md#alpha
altGeneral[alt: a; ...rest]Prints the first argument that is not nothing.stdlib/general.md#alt
andBoolean[and: a; b; c*]Performs a boolean AND operation on the operands and returns the result.stdlib/boolean.md#and
asinMath[asin: x]Calculates the arcsine (in radians) of x.stdlib/math.md#asin
assertAssertion[assert: condition; message?]Verifies that condition is true before continuing program execution.stdlib/assertion.md#assert
assert-eqAssertion[assert-eq: actual; expected; message?]Verifies that expected and actual are equal before continuing program execution.stdlib/assertion.md#assert-eq
assert-neqAssertion[assert-neq: actual; unexpected; message?]Verifies that unexpected and actual are not equal before continuing program execution.stdlib/assertion.md#assert-neq
assert-notAssertion[assert-not: condition; message?]Verifies that condition is false before continuing program execution.stdlib/assertion.md#assert-not
assocCollections[assoc: keys; values]Creates a map from a list of keys and a list of values. Each key in keys will be matched with the value at the same index in values.stdlib/collections.md#assoc
atanMath[atan: x]Calculates the arctangent (in radians) of x.stdlib/math.md#atan
atan2Math[atan2: y; x]Calculates the four-quadrant arctangent (in radians) of \(\frac{y}{x}\).stdlib/math.md#atan2
augmentCollections[augment: dst-map; src-map]Clones dst-map, adds the values from src-map to the values with matching keys on dst-map, then returns the resulting map.stdlib/collections.md#augment
augment-selfCollections[augment-self: dst-map; src-map]Adds the values from src-map to the values with matching keys on dst-map.stdlib/collections.md#augment-self
augment-thruCollections[augment-thru: dst-map; src-map]Adds the values from src-map to the values with matching keys on dst-map, then prints dst-map.stdlib/collections.md#augment-thru
callGeneral[call: func; args?]Calls func with an optional list of argument values.stdlib/general.md#call
catGeneral[cat: ...values]Prints each argument into the current scope.stdlib/general.md#cat
ceilMath[ceil: val]Prints the smallest integer that is greater than or equal to val.stdlib/math.md#ceil
charStrings[char: code]Prints the Unicode character represented by the Unicode code point code. If code doesn't correspond to a valid character, prints nothing.stdlib/strings.md#char
chunksCollections[chunks: collection; count]Splits collection into count sub-slices and prints a new list containing the results, making a best-effort to make each chunk the same size.stdlib/collections.md#chunks
clampMath[clamp: value; a; b]Prints value clamped to the inclusive range between a and b.stdlib/math.md#clamp
clearCollections[clear: collection]Removes all elements from a list or map.stdlib/collections.md#clear
cosMath[cos: x]Calculates the cosine of x.stdlib/math.md#cos
digGenerators[dig: count ? 1]Prints a uniformly random decimal digit. If count is specified, repeats count times.stdlib/generators.md#dig
dighGenerators[digh: count ? 1]Prints a uniformly random lowercase hexadecimal digit. If count is specified, repeats count times.stdlib/generators.md#digh
dignzGenerators[dignz: count ? 1]Prints a uniformly random non-zero decimal digit. If count is specified, repeats count times.stdlib/generators.md#dignz
divMath[div: lhs; rhs]Divides two values and prints the quotient.stdlib/math.md#div
ds-query-sourcesGeneral[ds-query-sources]Prints the list of currently registered data-source IDs.stdlib/general.md#ds-query-sources
ds-requestGeneral[ds-request: id; ...args]Calls a registered data source by ID and prints its result.stdlib/general.md#ds-request
eitherGeneral[either: condition; true-value; false-value]Prints true-value when condition is true, otherwise false-value.stdlib/general.md#either
elseAttributes & Control Flow[else]Marks the next block as the fallback branch after a previous conditional block.stdlib/control-flow.md#else
elseifAttributes & Control Flow[elseif: condition]Marks the next block as an else if branch following a previous conditional block.stdlib/control-flow.md#elseif
eqComparison[eq: lhs; rhs]Returns @true if lhs and rhs are equal.stdlib/comparison.md#eq
errorGeneral[error: message?]Raises a USER_ERROR runtime failure with an optional message.stdlib/general.md#error
fill-selfCollections[fill-self: list; value]Mutates list in place by replacing every element with value.stdlib/collections.md#fill-self
fill-thruCollections[fill-thru: list; value]Mutates list in place and then prints the same list handle.stdlib/collections.md#fill-thru
filterCollections[filter: list; predicate]Runs a predicate function against all items in a list and returns another list containing only the values that the predicate returned @true on.stdlib/collections.md#filter
floorMath[floor: val]Prints the largest integer that is less than or equal to val.stdlib/math.md#floor
forkGeneral[fork: seed?]Pushes a derived RNG onto the RNG stack. Integer and string seeds are both supported.stdlib/general.md#fork
fracMath[frac: val]Prints the fractional part of val.stdlib/math.md#frac
geComparison[ge: lhs; rhs]Returns @true if lhs is greater than or equal to rhs.stdlib/comparison.md#ge
gtComparison[gt: lhs; rhs]Returns @true if lhs is greater than rhs.stdlib/comparison.md#gt
hasCollections[has: collection; value]Returns a boolean indicating whether value occurs in collection.stdlib/collections.md#has
ifAttributes & Control Flow[if: condition]Marks the next block as conditional and resolves it only when condition is truthy.stdlib/control-flow.md#if
indentStrings[indent: text; indent]Prefixes every line in text with the string indent.stdlib/strings.md#indent
index-ofCollections[index-of: list; value]Returns the index of the first occurrence of value in list. If no match is found, returns <>.stdlib/collections.md#index-of
insertCollections[insert: collection; value; pos]Inserts value into a list or map at the position pos.stdlib/collections.md#insert
irangeGeneral[irange: a; b?; step?]Builds an inclusive integer range.stdlib/general.md#irange
isVerification[is: value; type-name]Returns @true when value's runtime type name exactly matches type-name.stdlib/verification.md#is
is-betweenVerification[is-between: value; a; b]Returns @true if value is bewteen a and b (both inclusive).stdlib/verification.md#is-between
is-boolVerification[is-bool: value]Returns @true if value is of type bool.stdlib/verification.md#is-bool
is-evenVerification[is-even: number]Returns @true if number is an even number.stdlib/verification.md#is-even
is-factorVerification[is-factor: value; factor]Returns @true if value is evenly divisible by factor.stdlib/verification.md#is-factor
is-floatVerification[is-float: value]Returns @true if value is of type float.stdlib/verification.md#is-float
is-intVerification[is-int: value]Returns @true if value is of type int.stdlib/verification.md#is-int
is-nanVerification[is-nan: value]Returns @true if value is of type float and equal to NaN (Not a Number).stdlib/verification.md#is-nan
is-nothingVerification[is-nothing: value]Returns @true if value is of type nothing.stdlib/verification.md#is-nothing
is-numberVerification[is-number: value]Returns @true if value is of type int or float.stdlib/verification.md#is-number
is-oddVerification[is-odd: number]Returns @true if number is an odd number.stdlib/verification.md#is-odd
is-someVerification[is-some: value]Returns @true if value is any non-nothing type.stdlib/verification.md#is-some
is-stringVerification[is-string: value]Returns @true if value is of type string.stdlib/verification.md#is-string
joinCollections[join: list; separator?]Prints the elements of a list in order separated by the separator value.stdlib/collections.md#join
keysCollections[keys: map]Prints a list of the keys stored in map.stdlib/collections.md#keys
last-index-ofCollections[last-index-of: list; value]Returns the index of the last occurrence of value in list. If no match is found, returns <>.stdlib/collections.md#last-index-of
leComparison[le: lhs; rhs]Returns @true if lhs is less than or equal to rhs.stdlib/comparison.md#le
lenGeneral[len: value]Prints the length of a string, list, map, range, or other length-aware value.stdlib/general.md#len
linesStrings[lines: str]Splits string str by line feed characters (0x0A, \n) and returns a list of the results.stdlib/strings.md#lines
listCollections[list: values*]Prints a list containing the arguments.stdlib/collections.md#list
lowerStrings[lower: str]Converts string str to lowercase and returns the result.stdlib/strings.md#lower
ltComparison[lt: lhs; rhs]Returns @true if lhs is less than rhs.stdlib/comparison.md#lt
mapCollections[map: list; map-func]Calls the supplied function on each item in a list and returns another list with the results in the same order.stdlib/collections.md#map
matchAttributes & Control Flow[match: value]Sets the active selector for the next block to a match selector bound to value.stdlib/control-flow.md#match
maxMath[max: values+]Returns the largest value in values.stdlib/math.md#max
maybeGenerators[maybe: p ? 0.5]Returns a bool value with p probability of being true.stdlib/generators.md#maybe
minMath[min: values+]Returns the smallest value in values.stdlib/math.md#min
mkselAttributes & Control Flow[mksel: selector-mode; match-value?]Creates and returns a selector with the specified mode. match mode requires a match value; all other modes reject one.stdlib/control-flow.md#mksel
modMath[mod: lhs; rhs]Gets the modulus of two values.stdlib/math.md#mod
mulMath[mul: lhs; rhs]Multiplies two values and prints the product.stdlib/math.md#mul
mul-addMath[mul-add: lhs; rhs; add]Multiplies two values, then adds another value to the result.stdlib/math.md#mul-add
mutAttributes & Control Flow[mut: mutator?]Sets the mutator function for the next block, or clears it when passed nothing.stdlib/control-flow.md#mut
negMath[neg: val]Negates a value and prints it.stdlib/math.md#neg
neqComparison[neq: lhs; rhs]Returns @true if lhs and rhs are not equal.stdlib/comparison.md#neq
nlistCollections[nlist: values*]Prints a single-element list whose only value is the list constructed from values.stdlib/collections.md#nlist
notBoolean[not: a]Returns the inverse of the input boolean value.stdlib/boolean.md#not
num-fmtFormatting[num-fmt: options?; depth ? 0]Gets or sets the number formatting options for the calling scope.stdlib/formatting.md#num-fmt
num-fmt-altFormatting[num-fmt-alt: flag?; depth ? 0]Gets or sets the number formatter's alternate format flag.stdlib/formatting.md#num-fmt-alt
num-fmt-decimal-sepFormatting[num-fmt-decimal-sep: decimal-sep?; depth ? 0]Gets or sets the number formatter's decimal separator.stdlib/formatting.md#num-fmt-decimal-sep
num-fmt-endianFormatting[num-fmt-endian: endianness?; depth ? 0]Gets or sets the number format's endianness. This affects the byte order of power-of-two base formats such as binary and hex.stdlib/formatting.md#num-fmt-endian
num-fmt-group-sepFormatting[num-fmt-group-sep: group-sep?; depth ? 0]Gets or sets the number formatter's digit group separator.stdlib/formatting.md#num-fmt-group-sep
num-fmt-infinityFormatting[num-fmt-infinity: infinity?; depth ? 0]Gets or sets the number formatter's infinity style.stdlib/formatting.md#num-fmt-infinity
num-fmt-paddingFormatting[num-fmt-padding: padding?; depth ? 0]Gets or sets the number formatter's digit padding size.stdlib/formatting.md#num-fmt-padding
num-fmt-precisionFormatting[num-fmt-precision: precision?; depth ? 0]Gets or sets the number formatter's decimal precision.stdlib/formatting.md#num-fmt-precision
num-fmt-signFormatting[num-fmt-sign: sign?; depth ? 0]Gets or sets the number formatter's sign style.stdlib/formatting.md#num-fmt-sign
num-fmt-systemFormatting[num-fmt-system: system?; depth ? 0]Gets or sets the number formatter's numeral system.stdlib/formatting.md#num-fmt-system
num-fmt-upperFormatting[num-fmt-upper: flag?; depth ? 0]Gets or sets the number formatter's uppercase formatting flag.stdlib/formatting.md#num-fmt-upper
orBoolean[or: a; b; c*]Performs a boolean inclusive OR operation on the operands and returns the result.stdlib/boolean.md#or
ordStrings[ord: ch]Prints the Unicode code point of the specified character as an int value. If an empty string is passed, prints nothing.stdlib/strings.md#ord
ord-allStrings[ord-all: str]Prints a list of int values containing the Unicode code points contained in str.stdlib/strings.md#ord-all
oxford-joinCollections[oxford-join: comma; conj; comma-conj; list]A variant of the join function for conveniently formatting comma-separated lists.stdlib/collections.md#oxford-join
pickGenerators[pick: collection]Prints a random element from an ordered collection.stdlib/generators.md#pick
pick-sparseGenerators[pick-sparse: first; ...rest]Randomly selects one value from a sparse weighted set of arguments by using each argument's length as its weight.stdlib/generators.md#pick-sparse
picknGenerators[pickn: collection; count]Prints a list containing count random elements sampled from collection.stdlib/generators.md#pickn
popCollections[pop: list]Removes the last value from a list and prints it.stdlib/collections.md#pop
powMath[pow: x; y]Calculates \(x^y\) and prints the result. Both x and y can be int or float.stdlib/math.md#pow
printGeneral[print: ...values]Prints values directly into the caller's output scope.stdlib/general.md#print
protoGeneral[proto: map]Prints the prototype map of map, or nothing if no prototype is set.stdlib/general.md#proto
pushCollections[push: list; value]Appends a value to the end of a list.stdlib/collections.md#push
randGenerators[rand: a; b]Prints a random integer with uniform distribution between a and b (both inclusive).stdlib/generators.md#rand
rand-listGenerators[rand-list: a; b; n]Prints a list of n random integers with uniform distribution between a and b (both inclusive).stdlib/generators.md#rand-list
rand-list-sumGenerators[rand-list-sum: input; count; variance]Generates a list of count random numbers, whose sum equals input, and with a maximum absolute difference of variance.stdlib/generators.md#rand-list-sum
randfGenerators[randf: a; b]Prints a random float with uniform distribution between a (inclusive) and b (exclusive).stdlib/generators.md#randf
randf-listGenerators[randf-list: a; b; n]Prints a list of n random floats with uniform distribution between a (inclusive) and b (exclusive).stdlib/generators.md#randf-list
rangeGeneral[range: a; b?; step?]Builds a half-open integer range.stdlib/general.md#range
recipMath[recip: n]Gets the reciprocal of a value.stdlib/math.md#recip
removeCollections[remove: collection; pos]Removes the value at the pos from a list or map.stdlib/collections.md#remove
repAttributes & Control Flow[rep: reps]Sets the repetition count or repetition mode for the next block.stdlib/control-flow.md#rep
requireGeneral[require: module-path]Imports a module through the active module resolver.stdlib/general.md#require
reset-attrsAttributes & Control Flow[reset-attrs]Resets the current attribute state back to the runtime defaults.stdlib/control-flow.md#reset-attrs
revCollections[rev: collection]Prints a reversed copy of the input collection.stdlib/collections.md#rev
seedGeneral[seed]Prints the currently active RNG seed as an int.stdlib/general.md#seed
segStrings[seg: str; size]Segments the input text into a list of strings of size length.stdlib/strings.md#seg
selAttributes & Control Flow[sel: selector?]Sets the active selector for the next block. With no argument, prints the current selector or nothing.stdlib/control-flow.md#sel
sel-freezeAttributes & Control Flow[sel-freeze: selector; frozen?]Sets the frozen state of selector. Omitting frozen freezes it. This is unsupported for match selectors.stdlib/control-flow.md#sel-freeze
sel-frozenAttributes & Control Flow[sel-frozen: selector]Prints whether selector is currently frozen. This is unsupported for match selectors.stdlib/control-flow.md#sel-frozen
sel-skipAttributes & Control Flow[sel-skip: selector; n?]Advances selector without printing any selected value. This is unsupported for match selectors.stdlib/control-flow.md#sel-skip
sepAttributes & Control Flow[sep: separator]Sets the separator value for repeated block iterations.stdlib/control-flow.md#sep
set-protoGeneral[set-proto: map; proto?]Sets or clears the prototype map for map.stdlib/general.md#set-proto
shuffleCollections[shuffle: list]Creates a shuffled copy of a list.stdlib/collections.md#shuffle
shuffle-selfCollections[shuffle-self: list]Shuffles the elements of a list in-place.stdlib/collections.md#shuffle-self
shuffle-thruCollections[shuffle-thru: list]Shuffles the elements of a list in-place, then prints the list.stdlib/collections.md#shuffle-thru
siftCollections[sift: list; target-size]Returns a copy of a list with random elements removed until the number of elements in the list copy reaches target-size. If the number of elements in the list is less than or equal to target-size, this function simply returns an exact copy of the original list.stdlib/collections.md#sift
sift-selfCollections[sift-self: list; target-size]Removes random elements from a list in-place until the number of elements in the list reaches target-size. If the number of elements in the list is less than or equal to target-size, this function does nothing.stdlib/collections.md#sift-self
sift-thruCollections[sift-thru: list; target-size]Removes random elements from a list in-place until the number of elements in the list reaches target-size. If the number of elements in the list is less than or equal to target-size, this function does nothing.stdlib/collections.md#sift-thru
sinMath[sin: x]Calculates the sine of x.stdlib/math.md#sin
sortCollections[sort: list]Creates a copy of a list with its elements sorted in ascending order.stdlib/collections.md#sort
sort-selfCollections[sort-self: list]Sorts the elements of a list in-place in ascending order.stdlib/collections.md#sort-self
sort-thruCollections[sort-thru: list]Sorts the elements of a list in-place in ascending order, then prints the list.stdlib/collections.md#sort-thru
splitStrings[split: str; sep?]Splits the input text by sep into a list of strings. If sep is omitted, splits into characters.stdlib/strings.md#split
sqrtMath[sqrt: x]Calculates the square root of x.stdlib/math.md#sqrt
squishCollections[squish: list; target-size]Returns a copy of a list with random adjacent elements merged using addition until the number of elements in the list copy reaches target-size. If the number of elements in the list is less than or equal to target-size, this function simply returns an exact copy of the original list.stdlib/collections.md#squish
squish-selfCollections[squish-self: list; target-size]Merges random adjacent elements in a list using addition until the number of elements in the list reaches target-size. If the number of elements in the list is less than or equal to target-size, this function does nothing.stdlib/collections.md#squish-self
squish-thruCollections[squish-thru: list; target-size]Merges random adjacent elements in a list using addition until the number of elements in the list reaches target-size, then prints the list. If the number of elements in the list is less than or equal to target-size, this function does nothing.stdlib/collections.md#squish-thru
stepAttributes & Control Flow[step]Prints the current repeater step value using a 1-based index.stdlib/control-flow.md#step
step-countAttributes & Control Flow[step-count]Prints the total number of iterations scheduled for the active repeater. Infinite repeaters report 0.stdlib/control-flow.md#step-count
step-indexAttributes & Control Flow[step-index]Prints the zero-based iteration index of the active repeater.stdlib/control-flow.md#step-index
string-replaceStrings[string-replace: input; query; replacement]Prints input with every occurrence of query replaced by replacement.stdlib/strings.md#string-replace
subMath[sub: lhs; rhs]Prints the difference between two values.stdlib/math.md#sub
sumCollections[sum: list]Adds the elements of a list together from left to right and prints the result.stdlib/collections.md#sum
takeCollections[take: collection; pos]Removes the value at pos from a list or map and prints it.stdlib/collections.md#take
tanMath[tan: x]Calculates the tangent of x.stdlib/math.md#tan
tapGeneral[tap: ...]Consumes arguments and produces no output. This is useful as a no-op sink in pipe chains.stdlib/general.md#tap
to-boolConversion[to-bool: value]Converts value to a boolean using Ranty's runtime truthiness rules.stdlib/conversion.md#to-bool
to-floatConversion[to-float: value]Attempts to convert value to a float value and prints the result. If the conversion fails, prints nothing.stdlib/conversion.md#to-float
to-intConversion[to-int: value]Attempts to convert value to an int value and prints the result. If the conversion fails, prints nothing.stdlib/conversion.md#to-int
to-listConversion[to-list: value]Attempts to convert value to a list and prints the result. If the conversion fails, prints nothing.stdlib/conversion.md#to-list
to-stringConversion[to-string: value]Attempts to convert value to a string value and prints the result. If the conversion fails, prints nothing.stdlib/conversion.md#to-string
to-tupleConversion[to-tuple: value]Attempts to convert a value to a tuple and prints the result. If the conversion fails, prints nothing.stdlib/conversion.md#to-tuple
translateCollections[translate: list; map]Matches each item in a list to a map and returns a list with the corresponding map values. Values that have no corresponding key in the map are passed through as-is. For maps with prototypes, [translate] uses only keys stored directly on the provided map.stdlib/collections.md#translate
trimStrings[trim: str]Prints str with leading and trailing whitespace removed.stdlib/strings.md#trim
tryGeneral[try: context; handler?]Runs context and optionally dispatches runtime failures to handler.stdlib/general.md#try
tupleCollections[tuple: values*]Prints a tuple containing the arguments.stdlib/collections.md#tuple
typeGeneral[type: value]Prints the runtime type name of value.stdlib/general.md#type
unforkGeneral[unfork]Pops the most recent derived RNG and resumes the previous RNG state.stdlib/general.md#unfork
upperStrings[upper: str]Converts string str to uppercase and returns the result.stdlib/strings.md#upper
valuesCollections[values: map]Prints a list of the values stored in map.stdlib/collections.md#values
ws-fmtFormatting[ws-fmt: mode?; custom?]Gets or sets the whitespace normalization mode for the current scope. custom is only used when mode is custom.stdlib/formatting.md#ws-fmt
xorBoolean[xor: a; b]Performs a boolean XOR operation on the operands and returns the result.stdlib/boolean.md#xor
zipCollections[zip: list-a; list-b; zip-func]Returns a new list that combines each pair of items from the two input lists using the specified function. The lists do not need to be the same length; if there is a difference, it will be made up with empties.stdlib/collections.md#zip