SPVM::I...LongList(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ’… SPVM::Immutable::LongList β€” the manual page, but make it make sense

Okay bestie, so this page is SPVM::Immutable::LongList(3) from the user-contributed Perl docs, and it's literally all about one thing: an immutable long array. Iconic. Let's get into it. πŸ¦‹


✨ Name ✨

SPVM::Immutable::LongList β€” an immutable long array. That's the whole vibe. Once it's made, it's made. No take-backs, no edits, periodt. πŸ‘‘


🌸 Description 🌸

The Immutable::LongList class has methods to manipulate an immutable long array. Lowkey the chillest class in the whole ecosystem β€” it just holds your longs and refuses to change. Main character energy fr fr. πŸ’–


πŸŽ€ Usage πŸŽ€

Here's the whole group chat in action:

use Immutable::LongList;

# Create a long list
my $list = Immutable::LongList->new;
my $list = Immutable::LongList->new([(long)1, 2, 3]);

# Create a long list with array length
my $list = Immutable::LongList->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;

Like, that's it. That's the whole API and it ate. πŸ’…


🧚 Fields 🧚

🌈 length

has length : ro int;

Gets the length field. Read-only, so don't even think about touching it. πŸ™ˆ

This field is the length of the elements of the list. Simple as that. ✨


⭐ Class Methods ⭐

πŸ’œ new

static method new : Immutable::LongList ($array : long[] = undef);

Create a new Immutable::LongList object using new_len. Yes, it delegates. She's efficient like that. 🫢

The passed length to new_len is the length of the array. If the array is undef, the length is 0. No array? No problem. Zero vibes, but valid ones. πŸ’€

The elements of the array are copied to the elements of the the created array. (Yes, the original says "the the". We keep the the. Preserving history. 😭)

Examples:

my $list = Immutable::LongList->new;
my $list = Immutable::LongList->new([(long)1, 2, 3]);

πŸ“ new_len

static method new_len : Immutable::LongList ($length : int);

Creates a new Immutable::LongList object with $length. You tell it how long, it gives you the list. Slay. ✨

Exceptions:

  • $length must be greater than or equal to 0. Otherwise an exception is thrown. So like, negative lengths? Not today, bestie. 🚫

πŸ”₯ Instance Methods πŸ”₯

πŸ’– get

method get : long ($index : int);

Gets the element of the position of $index. Very "give me the thing at this spot" of it. 🎯

If $index is a netative value, $index is set to length plus $index. (Yeah, the manpage says "netative" β€” we're keeping the typo, it's canon now. 😭) So you can index from the end like a cool person. πŸ’…

Exceptions:

  • $index must be greater than or equal to 0. Otherwise an exception is thrown. πŸ’€
  • $index must be less than the length of $list. Otherwise an exception is thrown. Don't go out of bounds, it's embarrassing. πŸ™ˆ

πŸ¦‹ to_array

method to_array : long[] ();

Converts the list to an array. Glow-up complete β€” the list becomes an array and honestly? Both are valid. 🌈⭐


Copyright (c) 2023 Yuki Kimoto

MIT License

Ngl, MIT License is the "yes bestie, do whatever, just give credit" of licenses. Iconic and permissive. 🫢

And that's the tea! 🍡 Mwah, thanks for reading, bestie β€” per the footer this was perl v5.42.2, dated 2026-02-03, on the SPVM::I...LongList(3) page. Go forth and build immutable long arrays, you gorgeous genius. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from