This queue is for tickets about the List-MoreUtils CPAN distribution.

Report information
The Basics
 Id: 94382 Status: resolved Priority: 0/ Queue: List-MoreUtils

People
 Owner: Nobody in particular Requestors: Duarte.Molha [...] ogt.com Cc: AdminCc:

Bug Information
 Severity: (no value) Broken in: (no value) Fixed in: 0.407

History
 Subject: Error in documentation for uniq and distinct method calls Date: Wed, 2 Apr 2014 14:32:42 +0000 To: "bug-List-MoreUtils [...] rt.cpan.org" From: Duarte Molha
text/plain 803b
Hi I have detected an error in the documentation of a method: uniq LIST distinct LIST Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 I believe the corrected version should be : uniq LIST distinct LIST Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @x = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 Best regards Duarte Molha

Message body is not shown because it is too large.

text/plain 307b
Can you explain what is wrong? perl -MList::MoreUtils=uniq,distinct -MDDP -e 'my @x = distinct 1, 1, 2, 2, 3, 5, 3, 4; my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; p(@x); p(\$x);' [ [0] 1, [1] 2, [2] 3, [3] 5, [4] 4 ] 5 Or do you hint on having both function names in the example? Cheers, Jens
 Subject: RE: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls Date: Wed, 2 Apr 2014 14:56:30 +0000 To: "bug-List-MoreUtils [...] rt.cpan.org" From: Duarte Molha
I do not mean the functions are not working correctly... I mean that the documentation for the distinct method is wrong or better yet - non existent Or maybe I am just fundamentaly not understanding the documentation. On the CPAN webpage for the module this is what says on the documentation: uniq LIST distinct LIST Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 So is uniq and distinct the same method??? This is what I thought it would be. Please correct me if I am wrong on my assumption: uniq LIST Returns a new list by keeping only unique values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @u = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5,4 my \$u = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 2 distinct LIST Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST. my @d = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my \$d = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 Best regards Duarte Show quoted text
-----Original Message----- From: Jens Rehsack via RT [mailto:bug-List-MoreUtils@rt.cpan.org] Sent: 02 April 2014 15:40 To: Duarte Molha Subject: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls <URL: https://rt.cpan.org/Ticket/Display.html?id=94382 > Can you explain what is wrong? perl -MList::MoreUtils=uniq,distinct -MDDP -e 'my @x = distinct 1, 1, 2, 2, 3, 5, 3, 4; my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; p(@x); p(\$x);' [ [0] 1, [1] 2, [2] 3, [3] 5, [4] 4 ] 5 Or do you hint on having both function names in the example? Cheers, Jens
text/plain 1.7k
On Wed Apr 02 10:56:46 2014, Duarte.Molha@ogt.com wrote: Show quoted text
> I do not mean the functions are not working correctly...
Ok, I got mislead :) Show quoted text
> I mean that the documentation for the distinct method is wrong or > better yet - non existent > Or maybe I am just fundamentaly not understanding the documentation. > > On the CPAN webpage for the module this is what says on the > documentation: > > uniq LIST > distinct LIST > Returns a new list by stripping duplicate values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 > my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 > > > So is uniq and distinct the same method???
Yes, they're the same function, just two names. Similar to mesh and zip, firstidx and first_index etc. Show quoted text
> This is what I thought it would be. Please correct me if I am wrong on > my assumption: > > uniq LIST > Returns a new list by keeping only unique values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @u = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5,4 > my \$u = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 2
Nope, uniq returns a list of uniq values, removing all values which occur more than once. Show quoted text
> distinct LIST > Returns a new list by stripping duplicate values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @d = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 > my \$d = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 5
This is correct for both. Cheers Jens
 Subject: RE: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls Date: Wed, 2 Apr 2014 15:03:43 +0000 To: "bug-List-MoreUtils [...] rt.cpan.org" From: Duarte Molha
text/plain 2.2k
So is there no option to do a uniq that return only the values that have no duplicates, similarly to what you get with "uniq -u" in bash? Thanks Show quoted text
-----Original Message----- From: Jens Rehsack via RT [mailto:bug-List-MoreUtils@rt.cpan.org] Sent: 02 April 2014 16:02 To: Duarte Molha Subject: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls <URL: https://rt.cpan.org/Ticket/Display.html?id=94382 > On Wed Apr 02 10:56:46 2014, Duarte.Molha@ogt.com wrote:
> I do not mean the functions are not working correctly...
> I mean that the documentation for the distinct method is wrong or > better yet - non existent Or maybe I am just fundamentaly not > understanding the documentation. > > On the CPAN webpage for the module this is what says on the > documentation: > > uniq LIST > distinct LIST > Returns a new list by stripping duplicate values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 > my \$x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 > > > So is uniq and distinct the same method???
Yes, they're the same function, just two names. Similar to mesh and zip, firstidx and first_index etc.
> This is what I thought it would be. Please correct me if I am wrong on > my assumption: > > uniq LIST > Returns a new list by keeping only unique values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @u = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5,4 my \$u = uniq 1, 1, > 2, 2, 3, 5, 3, 4; # returns 2
Nope, uniq returns a list of uniq values, removing all values which occur more than once.
> distinct LIST > Returns a new list by stripping duplicate values in LIST. The order of > elements in the returned list is the same as in LIST. In scalar > context, returns the number of unique elements in LIST. > my @d = distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my \$d = > distinct 1, 1, 2, 2, 3, 5, 3, 4; # returns 5
This is correct for both. Cheers Jens
Nope, not really. But I'm open for suggestions (combined with a good name).
 Subject: RE: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls Date: Wed, 2 Apr 2014 15:10:04 +0000 To: "bug-List-MoreUtils [...] rt.cpan.org" From: Duarte Molha
text/plain 600b
Singletons ? In mathematics, a singleton, also known as a unit set,[1] is a set with exactly one element. For example, the set {0} is a singleton. my @x = singletons 1,1,2,2,3,4,5 # returns (3,4,5) Cheers Duarte Show quoted text
-----Original Message----- From: Jens Rehsack via RT [mailto:bug-List-MoreUtils@rt.cpan.org] Sent: 02 April 2014 16:05 To: Duarte Molha Subject: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls <URL: https://rt.cpan.org/Ticket/Display.html?id=94382 > Nope, not really. But I'm open for suggestions (combined with a good name).
 Subject: Re: [rt.cpan.org #94382] Error in documentation for uniq and distinct method calls Date: Wed, 2 Apr 2014 18:44:17 +0200 To: bug-List-MoreUtils [...] rt.cpan.org From: Jens Rehsack