```{index} single: List::MoreUtils::XS ``` # List::MoreUtils::XS ```{pperl-module-badges} List::MoreUtils::XS ``` The compiled implementation of List::MoreUtils: the list functions List::Util does not have - junctions (`any`, `all`, `none`, `notall`, `one` and their `_u` variants that answer undef for an empty list), index and value searches from either end (`firstidx`, `lastval`, `onlyres`, ...), slicing by a predicate (`after`, `before_incl`), iterators (`each_array`, `natatime`, `slideatatime`), merging (`mesh`, `zip6`, `pairwise`, `arrayify`), counting (`uniq`, `singleton`, `duplicates`, `frequency`, `occurrences`, `mode`), binary searches over sorted lists (`bsearch`, `lower_bound`, `equal_range`, `binsert`, `bremove`) and an in-place `qsort`. This is a native implementation of List::MoreUtils::XS 0.430's `XS.xs`; its `List/MoreUtils/XS.pm` is used unchanged, and List::MoreUtils, which picks it as its backend, comes from CPAN. ## Synopsis ```perl use List::MoreUtils qw(firstidx pairwise natatime uniq); my $i = firstidx { $_ eq 'b' } qw(a b c); # 1 my @s = pairwise { $a + $b } @x, @y; my $it = natatime 3, 1 .. 10; while (my @chunk = $it->()) { print "@chunk\n" } my $n = uniq 1, 1, 2, undef, undef; # 3 ``` ## Differences from upstream - A block that is a compiled sub (`any \&Scalar::Util::blessed, ...`) is called; perl jumps into it as if it were Perl code and crashes. - `minmax` over objects that overload only other operators, with `fallback => 1`, compares their numeric values as `<=>` would; perl crashes. An overloaded `<=>` that returns a string or a fraction is read as a number; perl reads an unrelated field and answers wrongly (the maximum of 3, 1, 2 comes out as 2). - `reduce_u`, `reduce_0` and `reduce_1` leave the caller's `$_` alone; perl overwrites it with the last index, which changes the current element of an enclosing `for (@array)` and dies inside `for (1)` with "Modification of a read-only value attempted". - `frequency` no longer leaks a scalar per call when the list holds undef. - An object that overloads `@{}` over a hash or a scalar is read through its overloading by `arrayify`, `mesh`, `zip6`, `listcmp`, `each_array`, `insert_after` and `insert_after_string`; perl reads the hash as an array and crashes. - An array with holes (`$a[5] = 1` on an empty array) is read with undef in the holes by `arrayify`, `each_array`, `insert_after` and `insert_after_string`; perl crashes. - Calling the iterator bodies `List::MoreUtils::XS::_array_iterator` and `_slideatatime_iterator` directly returns an empty list; perl crashes.