Skip to content

@lang:slice

Extract a section of an array.

On-chain (@lang:slice!): Supports typed arrays and live signed indices. Bounds clamp to the array length and end is exclusive, matching the off-chain helper.

Returns: array

@lang:slice(value start end?)
NameTypeDescription
valuearraySource array
startnumberStart index (inclusive; negative counts from the end)
[end]numberEnd index (exclusive; negative counts from the end; omitted = to the end)
  • @at — access a single element
  • @len — array length

Slice a typed array using signed indexes, an inclusive start and exclusive end. Negative indexes count from the end; bounds clamp to the array length and reversed ranges yield an empty array. Source and indexes remain live until execution. Multiword elements retain their type.