List::M...tils::XS(3)

πŸ’– List::MoreUtils::XS β€” the compiled bestie backend πŸ’–

ok so real talk: this is the List::MoreUtils::XS page from the User Contributed Perl Documentation collection, and it's basically the turbo-charged compiled sidekick of List::MoreUtils. It doesn't want the spotlight, it just wants to make your list functions go fast ✨


🌸 NAME

List::MoreUtils::XS β€” Provide compiled List::MoreUtils functions πŸŽ€

Like, that's the whole vibe. Compiled versions of the functions you already know and love.


πŸ¦‹ SYNOPSIS

ok watch this, bestie πŸ‘‘

use List::MoreUtils::XS (); # doesn't export anything
use List::MoreUtils ':all'; # required to import functions

my @procs = get_process_stats->fetchall_array;
# sort by ppid, then pid
qsort { $a->[3] <=> $b->[3] or $a->[2] <=> $b->[2] } @procs;
while( @procs ) {
    my $proc = shift @procs;
    my @children = equal_range { $_->[3] <=> $proc->[2] } @procs;
}

my @left = qw(this is a test);
my @right = qw(this is also a test);
my %rlinfo = listcmp @left, @right;

# on unsorted
my $i = firstidx { $_ eq 'yeah' } @foo;
# on sorted - always first, but might not be 'yeah'
my $j = lower_bound { $_ cmp 'yeah' } @bar;
# on sorted - any of occurrences, is surely 'yeah'
my $k = bsearchidx { $_ cmp 'yeah' } @bar;

🚨 important vibe check: notice that use List::MoreUtils::XS (); exports nothing. Like, zero, nada. It's giving "I'm just here to do the work behind the scenes" energy πŸ’… If you actually want the functions to show up in your namespace, you gotta do use List::MoreUtils ':all'; β€” that's the non-negotiable part, fr fr.

Also peep the little comments in there, because they're actually doing a lot of heavy lifting:

  • firstidx is the one you use on unsorted data
  • lower_bound is for sorted data β€” and it's always first, but it might not be 'yeah' 😭
  • bsearchidx is for sorted data too β€” it finds any of the occurrences, and it is surely 'yeah' βœ…

🧚 DESCRIPTION

List::MoreUtils::XS is a backend for List::MoreUtils. That's it. That's the job. πŸ’–

And yeah, technically it could be practically independent from List::MoreUtils β€” because sometimes users wish for things like that β€” but it technically depends on List::MoreUtils. Like, it's not escaping that relationship, sorry bestie πŸ™ˆ

⚠️ and here's the part you really need to hear: since it's only a backend, the API is not public and can change without any warning. No cap. No deprecation cycle, no heads-up text, no "hey bestie just so you know." So don't go building your whole personality on it, mkay? πŸ’€

πŸŽ€ SEE ALSO

  • List::Util
  • List::AllUtils

go give them a follow, they're iconic in their own right πŸ‘‘


πŸ‘‘ AUTHOR

  • Jens Rehsack <rehsack AT cpan.org>
  • Adam Kennedy <adamk@cpan.org>
  • Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de>

the founding mothers (well, authors) of this whole situation 🫢


Some parts copyright 2011 Aaron Crane.

Copyright 2004 - 2010 by Tassilo von Parseval

Copyright 2013 - 2017 by Jens Rehsack

ok so the licensing lore is a lil split, pay attention πŸ“œβœ¨

All code added with 0.417 or later is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

All code until 0.416 is licensed under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

πŸ’€ seriously though, the "AS IS" / "WITHOUT WARRANTIES" bit is not a joke β€” that's the actual legal wording and it means exactly what it says.

k that's the whole page, bestie πŸ¦‹ this cutie was served up by perl v5.42.0, dated 2020-10-22, and it lives at List::M...tils::XS(3) in the manual β€” mwah πŸ’‹βœ¨ go write some fast list code, ily πŸ«ΆπŸ“

πŸ“¦ where this page comes from