SHARYANTO::List::Util(3pm) | User Contributed Perl Documentation | SHARYANTO::List::Util(3pm) |
SHARYANTO::List::Util - List utilities
This document describes version 0.77 of SHARYANTO::List::Util (from Perl distribution SHARYANTO-Utils), released on 2015-09-04.
Not exported by default but exportable.
Remove adjacent duplicates from list, i.e. behave more like Unix utility's uniq instead of List::MoreUtils's "uniq" function, e.g.
my @res = uniq(1, 4, 4, 3, 1, 1, 2); # 1, 4, 3, 1, 2
Like "uniq_adj" except case-insensitive.
Like "List::MoreUtils"' "uniq" except case-insensitive.
Given a list of integers, return number(s) missing in the sequence, e.g.:
find_missing_nums_in_seq(1, 2, 3, 4, 7, 8); # (5, 6)
Like "find_missing_nums_in_seq", but for strings/letters "a".."z".
find_missing_strs_in_seq("a", "e", "b"); # ("c", "d") find_missing_strs_in_seq("aa".."zu", "zz"); # ("zv", "zw", "zx", "zy")
Find lowest number $num in @list which still satisfies "$lower <= $num <= $upper". $lower and/or $upper can be undef to express no limit.
Find lowest string $str in @list which still satisfies "$lower le $x le $upper". $lower and/or $upper can be undef to express no limit.
Find highest number $num in @list which still satisfies "$lower <= $num <= $upper". $lower and/or $upper can be undef to express no limit.
Find highest string $str in @list which still satisfies "$lower le $x le $upper". $lower and/or $upper can be undef to express no limit.
Randomly pick an item from list. It is actually simply done as:
$_[@_ * rand]
Example:
pick(1, 2, 3); # => 2 pick(1, 2, 3); # => 1
Randomly pick "n" different items from list. Note that there might still be duplicate values in the result if the original list contains duplicates.
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)
SHARYANTO
Please visit the project's homepage at <https://metacpan.org/release/SHARYANTO-Utils>.
Source repository is at <https://github.com/perlancar/perl-SHARYANTO-Utils>.
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.
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.
2022-06-17 | perl v5.34.0 |