SPVM::Immutable::IntList - Immutable int Array
The Immutable::IntList class has methods to manipulate an immutable int array.
use Immutable::IntList; # Create a int list my $list = Immutable::IntList->new; my $list = Immutable::IntList->new([(int)1, 2, 3]); # Create a int list with array length my $list = Immutable::IntList->new_len(10); # Get list length my $length = $list->length; # Get value. my $element = $list->get(2); # Convert list to array. my $array = $list->to_array;
has length : ro int;
Gets the length field.
length
This field is the length of the elements of the list.
static method new : Immutable::IntList ($array = undef : int[]);
Create a new Immutable::IntList object using "new_len".
The passed length to "new_len" is the length of the array. If the array is undef, the length is 0.
The elements of the array are copied to the values of the the created array.
Examples:
my $list = Immutable::IntList->new; my $list = Immutable::IntList->new([(int)1, 2, 3]);
static method new_len : Immutable::IntList ($length : int);
Creates a new Immutable::IntList object with the $length.
Exceptions:
The $length must be greater than or equal to 0.
method get : int ($index : int);
Gets the element of the position of the $index.
The $index must be greater than or equal to 0.
The $index must be less than the length of the $list.
method to_array : int[] ();
Converts the list to an array.
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.