Skip to content

lang

Language primitives: string, number, bytes, array, and boolean helpers for data manipulation. Requires load lang (import the helpers you use, e.g. load lang [@map @filter], or qualify them as @lang:map).

load lang
HelperReturnsDescription
@lang:allboolWhether every element satisfies the predicate.
@lang:anyboolWhether at least one element satisfies the predicate.
@lang:atanyAccess an element by index in an array.
@lang:bytes.atbytesAccess a single byte by index in a bytes value.
@lang:bytes.concatbytesConcatenate bytes values together.
@lang:bytes.lennumberByte length of a bytes value (a UTF-8 character may span several bytes).
@lang:bytes.notbytesBitwise NOT of a bytes value (256-bit complement).
@lang:bytes.slicebytesExtract a byte range from a bytes value.
@lang:concatarrayConcatenate arrays together.
@lang:enumeratearrayPair every element of an array with its index.
@lang:filterarrayKeep elements of an array for which a helper returns truthy.
@lang:findanyFirst element that satisfies the predicate; no match is an error.
@lang:flatarrayFlatten one level of nesting in an array.
@lang:includesboolCheck whether an array contains an element.
@lang:keysarrayEntry names of a record ([a:1 b:2] or [name value] pairs), as an array.
@lang:lennumberLength of a value: element count for an array, byte length for a string or bytes.
@lang:lookupanyLook up an entry by name in a record ([a:1 b:2] or [name value] pairs).
@lang:maparrayTransform each element of an array by applying a helper.
@lang:num.formatstringFormat an integer in base units as ordinary decimal notation, trimming trailing fractional zeros.
@lang:num.parsenumberParse ordinary decimal notation into base units with explicit rounding and signedness.
@lang:reduceanyReduce an array to a single value by applying a helper.
@lang:reversearrayReverse the order of an array's elements.
@lang:slicearrayExtract a section of an array.
@lang:sortarraySort an array: ascending by default, desc for descending, or by a comparator helper.
@lang:str.atstringAccess one UTF-8 byte as a string; reject bytes belonging to multibyte characters.
@lang:str.charsetboolCheck whether every byte of a string is in a character class (ranges like a-z0-9-; a leading or trailing dash is the literal -).
@lang:str.concatstringConcatenate strings together.
@lang:str.includesboolCheck whether a string contains a substring (exact byte sequence, case-sensitive).
@lang:str.joinstringJoin array elements into a string with a delimiter.
@lang:str.lennumberLength of a string in UTF-8 bytes.
@lang:str.lowerstringConvert ASCII letters in a string to lowercase; preserve other characters.
@lang:str.replacestringReplace all occurrences of a substring (every non-overlapping left-to-right match).
@lang:str.slicestringExtract a UTF-8 byte range, with clamped indexes and complete characters.
@lang:str.splitarray | stringSplit a string by a delimiter into an array of strings, or select one segment when an index is given.
@lang:str.upperstringConvert ASCII letters in a string to uppercase; preserve other characters.
@lang:sumnumberSum the elements of an array.
@lang:uniquearrayRemove duplicates from an array, preserving first-occurrence order.
@lang:unziparrayTranspose an array of pairs into two separate arrays.
@lang:valuesarrayEntry values of a record ([a:1 b:2] or [name value] pairs), as an array.
@lang:ziparrayCombine two arrays element-wise into an array of pairs.