logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SHARYANTO::List::Util - List utilities

Author

       perlancar <perlancar@cpan.org>

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.

Functions

       Not exported by default but exportable.

   uniq_adj(@list)=>LIST
       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

   uniq_adj_ci(@list)=>LIST
       Like "uniq_adj" except case-insensitive.

   uniq_ci(@list)=>LIST
       Like "List::MoreUtils"' "uniq" except case-insensitive.

   find_missing_nums_in_seq(LIST)=>LIST
       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)

   find_missing_strs_in_seq(LIST)=>LIST
       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")

   min_in_range($lower,$upper,@list)=>$num
       Find lowest number $num in @list which still satisfies "$lower <= $num <= $upper". $lower and/or $upper
       can be undef to express no limit.

   minstr_in_range($lower,$upper,@list)=>$str
       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.

   max_in_range($lower,$upper,@list)=>$num
       Find highest number $num in @list which still satisfies "$lower <= $num <= $upper". $lower and/or $upper
       can be undef to express no limit.

   maxstr_in_range($lower,$upper,@list)=>$str
       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.

   pick(@list)=>$item
       Randomly pick an item from list. It is actually simply done as:

        $_[@_ * rand]

       Example:

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

   pick_n($n,@list)=>@picked
       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)

Homepage

       Please visit the project's homepage at <https://metacpan.org/release/SHARYANTO-Utils>.

Name

       SHARYANTO::List::Util - List utilities

See Also

       SHARYANTO

Source

       Source repository is at <https://github.com/perlancar/perl-SHARYANTO-Utils>.

Version

       This document describes version 0.77 of SHARYANTO::List::Util (from Perl distribution SHARYANTO-Utils),
       released on 2015-09-04.

See Also