Skip Menu |

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



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" <bug-List-MoreUtils [...] rt.cpan.org>
From: Duarte Molha <Duarte.Molha [...] ogt.com>
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.

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" <bug-List-MoreUtils [...] rt.cpan.org>
From: Duarte Molha <Duarte.Molha [...] ogt.com>
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
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" <bug-List-MoreUtils [...] rt.cpan.org>
From: Duarte Molha <Duarte.Molha [...] ogt.com>
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...
Ok, I got mislead :)
> 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" <bug-List-MoreUtils [...] rt.cpan.org>
From: Duarte Molha <Duarte.Molha [...] ogt.com>
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 <rehsack [...] gmail.com>
Am 02.04.2014 um 17:10 schrieb Duarte Molha via RT <bug-List-MoreUtils@rt.cpan.org>: Show quoted text
> Queue: List-MoreUtils > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=94382 > > > 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) >
Sounds reasonable. During 0.400_nnn I will update documentation to clarify function aliasing. After 0.401 I start implement new functions - including singletons. Cheers -- Jens Rehsack rehsack@gmail.com
Added support for "singleton" in 9d12b62 - please check whether it suits ;)