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:allboolReturn true if every element satisfies the predicate.
@lang:anyboolReturn true if 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.lennumberReturn the byte length of a bytes value.
@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:enumeratearrayReturn an array of [index, element] pairs.
@lang:filterarrayKeep elements of an array for which a helper returns truthy.
@lang:findanyReturn the first element that satisfies the predicate.
@lang:flatarrayFlatten one level of nesting in an array.
@lang:includesboolCheck whether an array contains an element.
@lang:lennumberReturn the length of an array.
@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:reversearrayReturn a new array with elements in reverse order.
@lang:slicearrayExtract a section of an array.
@lang:sortarraySort an array using a comparator helper.
@lang:str.atstringAccess a character by index in a string.
@lang:str.concatstringConcatenate strings together.
@lang:str.includesboolCheck whether a string contains a substring.
@lang:str.joinstringJoin array elements into a string with a delimiter.
@lang:str.lennumberReturn the length of a string.
@lang:str.lowerstringConvert a string to lowercase.
@lang:str.replacestringReplace all occurrences of a substring.
@lang:str.slicestringExtract a section of a string.
@lang:str.splitarraySplit a string by a delimiter into an array of strings.
@lang:str.upperstringConvert a string to uppercase.
@lang:uniquearrayRemove duplicates from an array, preserving first-occurrence order.
@lang:unziparrayTranspose an array of pairs into two separate arrays.
@lang:ziparrayCombine two arrays element-wise into an array of pairs.