Help for this page

Select Code to Download


  1. or download this
    use List::Util 'reduce';
    
    sub uniq {
        return @{;reduce {ref $a or $a=[$a]; push @$a, $b if $b ne $a->[-1
    +]; $a} @_};
    };
    
  2. or download this
    sub uniq {
        return @_ ? @_[0, grep {$_[$_] ne $_[$_-1]} 1..$#_] : ();
    };