BuiltinArray

scalus.uplc.builtin.BuiltinArray
See theBuiltinArray companion object
class BuiltinArray[A]

A builtin array type corresponding to the Plutus Core builtin array (CIP-0156).

Arrays provide O(1) indexed access to elements, complementing linked lists which have O(n) access time. This makes arrays ideal for random access patterns.

Arrays are created from lists using listToArray and provide efficient indexed access via indexArray and multiIndexArray.

==UPLC Builtin Operations==

The following UPLC builtins operate on arrays (available in Plutus V4+):

  • listToArray - Convert a list to an array
  • lengthOfArray - Get the number of elements
  • indexArray - Access element at index (O(1))
  • multiIndexArray - Access multiple elements by indices

Type parameters

A

the element type

Attributes

See also
Since

Plutus V4

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply(n: BigInt): A

Accesses the element at the given index.

Accesses the element at the given index.

Corresponds to UPLC builtin indexArray.

Value parameters

n

the zero-based index

Attributes

Returns

the element at index n

Throws
IndexOutOfBoundsException

if n is out of bounds

def length: BigInt

Returns the number of elements in the array.

Returns the number of elements in the array.

Corresponds to UPLC builtin lengthOfArray.

Attributes

Returns

the array length