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 a number with decimal places (like formatUnits).
@lang:num.parsenumberParse a decimal string with a given number of decimals (like parseUnits).
@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 a character by index in a string.
@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.
@lang:str.lowerstringConvert a string to lowercase.
@lang:str.replacestringReplace all occurrences of a substring (every non-overlapping left-to-right match).
@lang:str.slicestringExtract a section of a string.
@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 a string to uppercase.
@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.