NAME

List::Util::Uniq - List utilities related to finding unique items

VERSION

This document describes version 0.004 of List::Util::Uniq (from Perl distribution List-Util-Uniq), released on 2021-07-31.

SYNOPSIS

use List::Util::Uniq qw(
    is_monovalued
    is_monovalued_ci
    is_uniq
    is_uniq_ci
    uniq_adj
    uniq_adj_ci
    uniq_ci
);

$res = is_monovalued(qw/a a a/); # 1
$res = is_monovalued(qw/a b a/); # 0

$res = is_monovalued_ci(qw/a a A/); # 1
$res = is_monovalued_ci(qw/a b A/); # 0

$res = is_uniq(qw/a b a/); # 0
$res = is_uniq(qw/a b c/); # 1

$res = is_uniq_ci(qw/a b A/); # 0
$res = is_uniq_ci(qw/a b c/); # 1

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

@res = uniq_adj_ci("a", "b", "B", "c", "a"); # "a", "b", "c", "a"

@res = uniq_ci("a", "b", "B", "c", "a"); # "a", "b", "c"

FUNCTIONS

None exported by default but exportable.

uniq_adj

Usage:

my @uniq = uniq_adj(@list);

Remove adjacent duplicates from list, i.e. behave more like Unix utility's uniq instead of List::MoreUtils's uniq function. Uses string equality test.

uniq_adj_ci

Like "uniq_adj" except case-insensitive.

uniq_ci

Like List::MoreUtils' uniq (uniqstr) except case-insensitive.

is_uniq

Usage:

my $is_uniq = is_uniq(@list);

Return true when the values in @list is unique (compared string-wise). Knowing whether a list has unique values is faster using this function compared to doing:

my @uniq = uniq(@list);
@uniq == @list;

because of short-circuiting.

is_uniq_ci

Like "is_uniq" except case-insensitive.

is_monovalued

Usage:

my $is_monovalued = is_monovalued(@list);

Examples:

is_monovalued(qw/a b c/); # => 0
is_monovalued(qw/a a a/); # => 1

Return true if @list contains only a single value. Returns true for empty list. Undef is coerced to empty string, so is_monovalued(undef) and is_monovalued(undef, undef) return true.

is_monovalued_ci

Like "is_monovalued" except case-insensitive.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/List-Util-Uniq.

SOURCE

Source repository is at https://github.com/perlancar/perl-List-Util-Uniq.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=List-Util-Uniq

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.

SEE ALSO

List::Util

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2018 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.