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

πŸ“¦
version 0.77 Β· 2 versions
  • 0.77 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.77 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– SHARYANTO::List::Util β€” the manual page, bestie edition πŸ’–

okay so you've landed on the manpage for SHARYANTO::List::Util (in the docs it shows up as SHARYA...t::Util(3pm) in the header, cute little nickname energy ✨). It's a Perl module, it's from the Perl distribution SHARYANTO-Utils, and it is literally just a bag of list utilities. Let's go πŸŽ€


🌸 NAME 🌸

SHARYANTO::List::Util β€” list utilities, periodt. πŸ’…


πŸ¦‹ VERSION πŸ¦‹

This document describes version 0.77 of SHARYANTO::List::Util (from Perl distribution SHARYANTO-Utils), released on 2015-09-04. She's a lil vintage, we love her anyway πŸ’œ


✨ FUNCTIONS ✨

Real talk: not exported by default, but they're exportable β€” so you gotta ask nicely if you want them in your namespace. 🫢

🌈 uniq_adj(@list) => LIST

Removes adjacent duplicates from a list. The way this works is it behaves more like the Unix utility's uniq instead of List::MoreUtils's uniq function, iykyk. Example bestie:

my @res = uniq(1, 4, 4, 3, 1, 1, 2); # 1, 4, 3, 1, 2

See how the 1s and 4s that aren't next to each other stayed? Yeah. That's the whole vibe. πŸ’€

🌈 uniq_adj_ci(@list) => LIST

Exactly like uniq_adj, except it's case-insensitive. Same energy, lowercase who? Don't know her. πŸ™ˆ

🌈 uniq_ci(@list) => LIST

Just like List::MoreUtils' uniq, except case-insensitive. So it's the global dedupe but it doesn't care about your caps lock. πŸ’…

πŸ“ find_missing_nums_in_seq(LIST) => LIST

Hand it a list of integers and it hands back the number(s) that are missing in the sequence. Iconic detective behaviour fr fr:

find_missing_nums_in_seq(1, 2, 3, 4, 7, 8); # (5, 6)

She found the gap. Obsessed. ✨

πŸ“ find_missing_strs_in_seq(LIST) => LIST

Same thing as find_missing_nums_in_seq but for strings/letters "a".."z". Look:

find_missing_strs_in_seq("a", "e", "b"); # ("c", "d")
find_missing_strs_in_seq("aa".."zu", "zz"); # ("zv", "zw", "zx", "zy")

Not me checking the alphabet on her behalf 😭 she's thorough.

πŸ‘‘ min_in_range($lower, $upper, @list) => $num

Find the lowest number $num in @list that still satisfies $lower <= $num <= $upper. And here's the flexible part β€” $lower and/or $upper can be undef to express no limit. No limit, no problem, main character energy. πŸ’œ

πŸ‘‘ minstr_in_range($lower, $upper, @list) => $str

Find the lowest string $str in @list that still satisfies $lower le $x le $upper. Same deal: $lower and/or $upper can be undef to express no limit. πŸ¦‹

πŸ‘‘ max_in_range($lower, $upper, @list) => $num

Find the highest number $num in @list that still satisfies $lower <= $num <= $upper. And yes, $lower and/or $upper can be undef to express no limit. πŸ’–

πŸ‘‘ maxstr_in_range($lower, $upper, @list) => $str

Find the highest string $str in @list that still satisfies $lower le $x le $upper. $lower and/or $upper can be undef to express no limit. Slay. ⭐

πŸŽ€ pick(@list) => $item

Randomly pick one item from the list. And ngl it's actually simply done as:

$_[@_ * rand]

That's it. That's the whole trick. Example:

pick(1, 2, 3); # => 2
pick(1, 2, 3); # => 1

Random is random, bestie, don't come for me πŸ’€

πŸŽ€ pick_n($n, @list) => @picked

Randomly pick n different items from the list. But okay, important caveat so you're not blindsided: there might still be duplicate values in the result if the original list contains duplicates. She picks different positions, not necessarily different values, okay?? 😭

pick_n(3, 1,2,3,4,5); # => (3,2,5)
pick_n(2, 1,2,3,4,5); # => (3,1)
pick_n(2, 1,1,1,1);   # => (1,1)
pick_n(4, 1,2,3);     # => (3,1,2)

See that (1,1)? That's the duplicate situation happening live. Not a bug, it's the documented vibe. πŸ”₯


🌈 SEE ALSO 🌈

  • SHARYANTO

🏠 HOMEPAGE 🏠

Please visit the project's homepage at <https://metacpan.org/release/SHARYANTO-Utils>. Go say hi πŸ’–


πŸ“¦ SOURCE πŸ“¦

Source repository is at <https://github.com/perlancar/perl-SHARYANTO-Utils>. The code lives there, go peek πŸ¦‹


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-Utils>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. Fr fr, a repro is the love language here β€” no repro, no idea what's happening, bestie 🫢


πŸ‘‘ AUTHOR πŸ‘‘

perlancar <perlancar@cpan.org>


This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Iconic licensing behaviour, we love a permissive queen ✨


okay that's the whole page!! and for the cute sign-off: this beauty was generated by perl v5.34.0 on 2022-06-17, and the page itself answers to SHARYA...t::Util(3pm) in the header and footer πŸ’…πŸŽ€ bye bestie, go dedupe something πŸ¦‹

πŸ“¦ where this page comes from