List::Util#

Native implementation of List::Util

Provides list utility functions (first, sum, min, max, reduce, etc.)

Perl Equivalent#

This module provides Rust-native implementations of functions from List::Util. Since PetaPerl does not support XS, these are implemented directly in Rust.

Block-Based Functions#

Functions like first, any, all, none, notall, and reduce in Perl take a block argument. These use the &@ prototype which tells the parser to treat func { block } @list syntax correctly.

Synopsis#

use List::Util qw(sum min max first any all reduce uniq);

my $total = sum @numbers;
my $smallest = min @numbers;
my $largest  = max @numbers;

my $found = first { $_ > 10 } @numbers;
my $has_neg = any { $_ < 0 } @numbers;
my $all_pos = all { $_ > 0 } @numbers;

my $product = reduce { $a * $b } @numbers;
my @unique  = uniq @strings;