diff -Nru liblist-utilsby-perl-0.11/Changes liblist-utilsby-perl-0.12/Changes --- liblist-utilsby-perl-0.11/Changes 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/Changes 2022-04-29 15:33:11.000000000 +0000 @@ -1,5 +1,12 @@ Revision history for List-UtilsBy +0.12 2022-04-29 + [CHANGES] + * Documentation updates: + + Add examples showing combining multiple functions to give + further behaviours + + Fixed typo "probability" (RT127988, RT136817) + 0.11 2018-01-31 23:12:44 [CHANGES] * Added 'minmax_by' (RT124275) diff -Nru liblist-utilsby-perl-0.11/debian/changelog liblist-utilsby-perl-0.12/debian/changelog --- liblist-utilsby-perl-0.11/debian/changelog 2018-12-21 19:44:10.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/changelog 2022-05-08 15:46:44.000000000 +0000 @@ -1,3 +1,25 @@ +liblist-utilsby-perl (0.12-1) unstable; urgency=medium + + * Team upload. + + [ gregor herrmann ] + * debian/watch: use uscan version 4. + + [ Debian Janitor ] + * Bump debhelper from old 10 to 12. + * Set debhelper-compat version in Build-Depends. + * Set upstream metadata fields: Repository. + * Bump debhelper from old 12 to 13. + + [ gregor herrmann ] + * Import upstream version 0.12. + * Update years of upstream copyright. + * Declare compliance with Debian Policy 4.6.0. + * Set Rules-Requires-Root: no. + * Annotate test-only build dependencies with . + + -- gregor herrmann Sun, 08 May 2022 17:46:44 +0200 + liblist-utilsby-perl (0.11-1) unstable; urgency=medium * Team upload. diff -Nru liblist-utilsby-perl-0.11/debian/compat liblist-utilsby-perl-0.12/debian/compat --- liblist-utilsby-perl-0.11/debian/compat 2018-12-21 19:44:10.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -10 diff -Nru liblist-utilsby-perl-0.11/debian/control liblist-utilsby-perl-0.12/debian/control --- liblist-utilsby-perl-0.11/debian/control 2018-12-21 19:44:10.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/control 2022-05-08 15:46:44.000000000 +0000 @@ -4,14 +4,15 @@ Section: perl Testsuite: autopkgtest-pkg-perl Priority: optional -Build-Depends: debhelper (>= 10), +Build-Depends: debhelper-compat (= 13), libmodule-build-perl -Build-Depends-Indep: libtest-pod-perl, +Build-Depends-Indep: libtest-pod-perl , perl -Standards-Version: 4.2.1 +Standards-Version: 4.6.0 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/liblist-utilsby-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/liblist-utilsby-perl.git Homepage: https://metacpan.org/release/List-UtilsBy +Rules-Requires-Root: no Package: liblist-utilsby-perl Architecture: all diff -Nru liblist-utilsby-perl-0.11/debian/copyright liblist-utilsby-perl-0.12/debian/copyright --- liblist-utilsby-perl-0.11/debian/copyright 2018-12-21 19:44:10.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/copyright 2022-05-08 15:46:44.000000000 +0000 @@ -4,7 +4,7 @@ Source: https://metacpan.org/release/List-UtilsBy Files: * -Copyright: 2009-2018, Paul Evans +Copyright: 2009-2022, Paul Evans License: Artistic or GPL-1+ Files: debian/* diff -Nru liblist-utilsby-perl-0.11/debian/upstream/metadata liblist-utilsby-perl-0.12/debian/upstream/metadata --- liblist-utilsby-perl-0.11/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/upstream/metadata 2022-05-08 15:46:44.000000000 +0000 @@ -0,0 +1,2 @@ +--- +Repository: http://bazaar.leonerd.org.uk/perl/List-UtilsBy diff -Nru liblist-utilsby-perl-0.11/debian/watch liblist-utilsby-perl-0.12/debian/watch --- liblist-utilsby-perl-0.11/debian/watch 2018-12-21 19:44:10.000000000 +0000 +++ liblist-utilsby-perl-0.12/debian/watch 2022-05-08 15:46:44.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 -https://metacpan.org/release/List-UtilsBy .*/List-UtilsBy-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +version=4 +https://metacpan.org/release/List-UtilsBy .*/List-UtilsBy-v?@ANY_VERSION@@ARCHIVE_EXT@$ diff -Nru liblist-utilsby-perl-0.11/lib/List/UtilsBy.pm liblist-utilsby-perl-0.12/lib/List/UtilsBy.pm --- liblist-utilsby-perl-0.11/lib/List/UtilsBy.pm 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/lib/List/UtilsBy.pm 2022-04-29 15:33:11.000000000 +0000 @@ -1,4 +1,4 @@ -# You may distribute under the terms of either the GNU General Public License +# it wouldn't hurt to add a new line for such a configuration. You may distribute under the terms of either the GNU General Public License # or the Artistic License (the same terms as Perl itself) # # (C) Paul Evans, 2009-2018 -- leonerd@leonerd.org.uk @@ -8,7 +8,7 @@ use strict; use warnings; -our $VERSION = '0.11'; +our $VERSION = '0.12'; use Exporter 'import'; @@ -589,7 +589,7 @@ Returns the list of values shuffled into a random order. The randomisation is not uniform, but weighted by the value returned by the C. The -probabilty of each item being returned first will be distributed with the +probability of each item being returned first will be distributed with the distribution of the weights, and so on recursively for the remaining items. =cut @@ -647,6 +647,28 @@ return @ret; } +=head1 EXAMPLES + +As many of these functions both take and return lists of values, more useful +behaviours can be created by combining them together. + +=head2 Modal Value + +To pick the modal value in a list (i.e. the value that appears most +frequently according to some key function) combine C and C: + + my %counts = count_by { KEYFUNC } ITEMS; + my $modal = max_by { $counts{$_} } keys %counts; + +This can be performed in a single step by use of the C function from +L: + + use List::Util qw( pairs ); + + my $modal = ( max_by { $_->value } pairs count_by { KEYFUNC } ITEMS )->key; + +=cut + =head1 TODO =over 4 diff -Nru liblist-utilsby-perl-0.11/LICENSE liblist-utilsby-perl-0.12/LICENSE --- liblist-utilsby-perl-0.11/LICENSE 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/LICENSE 2022-04-29 15:33:11.000000000 +0000 @@ -1,4 +1,4 @@ -This software is copyright (c) 2018 by Paul Evans . +This software is copyright (c) 2022 by Paul Evans . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -12,7 +12,7 @@ --- The GNU General Public License, Version 1, February 1989 --- -This software is Copyright (c) 2018 by Paul Evans . +This software is Copyright (c) 2022 by Paul Evans . This is free software, licensed under: @@ -272,7 +272,7 @@ --- The Artistic License 1.0 --- -This software is Copyright (c) 2018 by Paul Evans . +This software is Copyright (c) 2022 by Paul Evans . This is free software, licensed under: @@ -292,21 +292,21 @@ - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through - textual modification. + textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright - Holder. + Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for - the package. + the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the - computing community at large as a market that must bear the fee.) + computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they - received it. + received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you @@ -373,7 +373,7 @@ 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End diff -Nru liblist-utilsby-perl-0.11/Makefile.PL liblist-utilsby-perl-0.12/Makefile.PL --- liblist-utilsby-perl-0.11/Makefile.PL 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/Makefile.PL 2022-04-29 15:33:11.000000000 +0000 @@ -1,14 +1,14 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.4220 +# Note: this file was auto-generated by Module::Build::Compat version 0.4231 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'List::UtilsBy', - 'VERSION_FROM' => 'lib/List/UtilsBy.pm', + 'EXE_FILES' => [], + 'PL_FILES' => {}, + 'INSTALLDIRS' => 'site', 'PREREQ_PM' => { 'Exporter' => '5.57' }, - 'INSTALLDIRS' => 'site', - 'EXE_FILES' => [], - 'PL_FILES' => {} + 'VERSION_FROM' => 'lib/List/UtilsBy.pm' ) ; diff -Nru liblist-utilsby-perl-0.11/MANIFEST liblist-utilsby-perl-0.12/MANIFEST --- liblist-utilsby-perl-0.11/MANIFEST 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/MANIFEST 2022-04-29 15:33:11.000000000 +0000 @@ -1,11 +1,8 @@ Build.PL Changes lib/List/UtilsBy.pm -LICENSE Makefile.PL MANIFEST This list of files -META.json -META.yml README t/00use.t t/01sort_by.t @@ -21,3 +18,6 @@ t/12bundle_by.t t/99pod.t t/Unrandom.pm +LICENSE +META.yml +META.json diff -Nru liblist-utilsby-perl-0.11/META.json liblist-utilsby-perl-0.12/META.json --- liblist-utilsby-perl-0.11/META.json 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/META.json 2022-04-29 15:33:11.000000000 +0000 @@ -4,7 +4,7 @@ "Paul Evans " ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.422", + "generated_by" : "Module::Build version 0.4231", "license" : [ "perl_5" ], @@ -33,7 +33,7 @@ "provides" : { "List::UtilsBy" : { "file" : "lib/List/UtilsBy.pm", - "version" : "0.11" + "version" : "0.12" } }, "release_status" : "stable", @@ -42,6 +42,6 @@ "http://dev.perl.org/licenses/" ] }, - "version" : "0.11", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "0.12", + "x_serialization_backend" : "JSON::PP version 4.06" } diff -Nru liblist-utilsby-perl-0.11/META.yml liblist-utilsby-perl-0.12/META.yml --- liblist-utilsby-perl-0.11/META.yml 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/META.yml 2022-04-29 15:33:11.000000000 +0000 @@ -7,7 +7,7 @@ configure_requires: Module::Build: '0.4004' dynamic_config: 1 -generated_by: 'Module::Build version 0.422, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4231, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -16,10 +16,10 @@ provides: List::UtilsBy: file: lib/List/UtilsBy.pm - version: '0.11' + version: '0.12' requires: Exporter: '5.57' resources: license: http://dev.perl.org/licenses/ -version: '0.11' +version: '0.12' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -Nru liblist-utilsby-perl-0.11/README liblist-utilsby-perl-0.12/README --- liblist-utilsby-perl-0.11/README 2018-01-31 23:21:27.000000000 +0000 +++ liblist-utilsby-perl-0.12/README 2022-04-29 15:33:11.000000000 +0000 @@ -298,7 +298,7 @@ Returns the list of values shuffled into a random order. The randomisation is not uniform, but weighted by the value returned by the - WEIGHTFUNC. The probabilty of each item being returned first will be + WEIGHTFUNC. The probability of each item being returned first will be distributed with the distribution of the weights, and so on recursively for the remaining items. @@ -315,6 +315,26 @@ If given a list of values whose length does not evenly divide by $number, the final call will be passed fewer elements than the others. +EXAMPLES + + As many of these functions both take and return lists of values, more + useful behaviours can be created by combining them together. + + Modal Value + + To pick the modal value in a list (i.e. the value that appears most + frequently according to some key function) combine count_by and max_by: + + my %counts = count_by { KEYFUNC } ITEMS; + my $modal = max_by { $counts{$_} } keys %counts; + + This can be performed in a single step by use of the pairs function + from List::Util: + + use List::Util qw( pairs ); + + my $modal = ( max_by { $_->value } pairs count_by { KEYFUNC } ITEMS )->key; + TODO * XS implementations