autobo...t::Util(3pm)

πŸ“¦
this version Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ NAME πŸ¦‹

autobox::List::Util β€” it brings the List::Util functions to autobox, bestie πŸ’–

(also hi, you're reading the autobo...t::Util(3pm) page from the User Contributed Perl Documentation β€” that's the whole vibe of this file, and we're gonna get into it)


⭐ VERSION ⭐

Version 20090629 ✨ (yes she's an elder, and yes she still slays)


πŸŽ€ SYNOPSIS πŸŽ€

Okay so here's the whole entire concept: "autobox::List::Util" brings all of the functions from List::Util to arrays as methods. Like, arrays get methods now. Main character energy fr fr πŸ‘‘

use autobox::List::Util;

my @array = qw/ foo bar baz /;

print @array->first(sub { /ar/ }), "\n"; # "bar"

print [5, 6, 3, 4]->max, "\n"; # 6

print @array->maxstr, "\n"; # baz

print [5, 6, 3, 4]->min, "\n"; # 3

print @array->minstr, "\n"; # foo

print [1 .. 10]->shuffle, "\n"; #1 to 10 randomly shuffled

print [1 .. 10]->sum, "\n"; # 55

print [1 .. 10]->reduce( sub { $a + $b } ), "\n"; # 55

Look at those comments, they're the receipts, keep them exactly as-is πŸ’…


🌸 METHODS 🌸

πŸ’œ first(coderef)

This one behaves nearly the same as the first function from List::Util, but β€” plot twist β€” it takes a coderef and not a block, because methods can't use prototypes. That's just the rules, no cap 😭

πŸ’œ reduce(coderef)

Same deal, bestie: this behaves nearly the same as the reduce function from List::Util, but it takes a coderef instead of a block, for the exact same reason (prototypes, methods, they don't mix, it's giving forbidden love πŸ™ˆ).

⚠️ Heads up though β€” it also has a bug. Scroll down to BUGS, I got you.

πŸ’œ shuffle

Iconic behaviour change incoming: if it's called in scalar context, it returns a reference to an array instead of a list. Why? So that shuffle can be chained with other calls. She's flexible like that πŸ¦‹βœ¨

πŸ’œ max, maxstr, min, minstr, sum

These methods behave exactly the same as their List::Util counterparts. No drama, no surprises, just the classics doing their thing πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Chas. J. Owens IV, "<chas.owens at gmail.com>" 🫢


πŸ’€ BUGS πŸ’€

Okay so the reduce method works with $main::a and $main::b, NOT your current package's $a and $b. So if you're not living in the main package, you literally have to say:

print @array->reduce( sub { $main::a + $main::b } ), "\n";

That's the workaround, periodt.

Good news though: reduce uses $_, so it doesn't suffer from this problem. One of them is fine, one of them is messy, it's giving sibling energy 😭


🌈 SUPPORT 🌈

You can find documentation for this module with the perldoc command:

perldoc autobox::List::Util

You can also look for information at:

  • 🌟 RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=autobox-List-Util

  • 🌟 AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/autobox-List-Util

  • 🌟 CPAN Ratings

http://cpanratings.perl.org/d/autobox-List-Util

  • 🌟 Search CPAN

http://search.cpan.org/dist/autobox-List-Util/


🧚 ACKNOWLEDGEMENTS 🧚

(no cap, this section is literally empty in the original β€” nothing to see here, moving on, she said nothing bestie πŸ’…)


Copyright 2009 Chas. J. Owens IV, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page!! πŸŽ€ she's perl v5.34.0, dated 2022-06-08, and she ate, no crumbs. byeeee 🫢✨🌈

πŸ“¦ where this page comes from