r73594 - in /trunk/liblist-utilsby-perl: ./ debian/ lib/List/ t/
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Tue Apr 26 08:30:06 UTC 2011
Author: angelabad-guest
Date: Tue Apr 26 08:29:50 2011
New Revision: 73594
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73594
Log:
* New upstream release
* debian/copyright: Update license stanzas
* Bump Standards-Version to 3.9.2 (no changes)
Added:
trunk/liblist-utilsby-perl/META.json
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/META.json
trunk/liblist-utilsby-perl/t/01sort_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/01sort_by.t
trunk/liblist-utilsby-perl/t/02nsort_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/02nsort_by.t
trunk/liblist-utilsby-perl/t/03max_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/03max_by.t
trunk/liblist-utilsby-perl/t/04min_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/04min_by.t
trunk/liblist-utilsby-perl/t/05uniq_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/05uniq_by.t
trunk/liblist-utilsby-perl/t/06partition_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/06partition_by.t
trunk/liblist-utilsby-perl/t/07count_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/07count_by.t
trunk/liblist-utilsby-perl/t/08zip_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/08zip_by.t
trunk/liblist-utilsby-perl/t/09extract_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/09extract_by.t
trunk/liblist-utilsby-perl/t/10weighted_shuffle_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/10weighted_shuffle_by.t
trunk/liblist-utilsby-perl/t/11bundle_by.t
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/11bundle_by.t
trunk/liblist-utilsby-perl/t/TestRand.pm
- copied unchanged from r73593, branches/upstream/liblist-utilsby-perl/current/t/TestRand.pm
Removed:
trunk/liblist-utilsby-perl/t/01sortby.t
trunk/liblist-utilsby-perl/t/02nsortby.t
trunk/liblist-utilsby-perl/t/03maxby.t
trunk/liblist-utilsby-perl/t/04minby.t
trunk/liblist-utilsby-perl/t/05uniqby.t
trunk/liblist-utilsby-perl/t/06partitionby.t
trunk/liblist-utilsby-perl/t/07zipby.t
trunk/liblist-utilsby-perl/t/08extract_by.t
Modified:
trunk/liblist-utilsby-perl/Build.PL
trunk/liblist-utilsby-perl/Changes
trunk/liblist-utilsby-perl/LICENSE
trunk/liblist-utilsby-perl/MANIFEST
trunk/liblist-utilsby-perl/META.yml
trunk/liblist-utilsby-perl/Makefile.PL
trunk/liblist-utilsby-perl/README
trunk/liblist-utilsby-perl/debian/changelog
trunk/liblist-utilsby-perl/debian/control
trunk/liblist-utilsby-perl/debian/copyright
trunk/liblist-utilsby-perl/lib/List/UtilsBy.pm
trunk/liblist-utilsby-perl/t/98back-compat.t
trunk/liblist-utilsby-perl/t/99pod.t
Modified: trunk/liblist-utilsby-perl/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/Build.PL?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/Build.PL (original)
+++ trunk/liblist-utilsby-perl/Build.PL Tue Apr 26 08:29:50 2011
@@ -6,6 +6,9 @@
my $build = Module::Build->new
(
module_name => 'List::UtilsBy',
+ requires => {
+ 'Exporter' => '5.57',
+ },
build_requires => {
'Test::More' => 0,
},
Modified: trunk/liblist-utilsby-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/Changes?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/Changes (original)
+++ trunk/liblist-utilsby-perl/Changes Tue Apr 26 08:29:50 2011
@@ -1,4 +1,7 @@
Revision history for List-UtilsBy
+
+0.07 CHANGES:
+ * Added 'count_by', 'weighted_shuffle_by', 'bundle_by'
0.06 CHANGES:
* Added 'rev_sort_by' and 'rev_nsort_by'
Modified: trunk/liblist-utilsby-perl/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/LICENSE?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/LICENSE (original)
+++ trunk/liblist-utilsby-perl/LICENSE Tue Apr 26 08:29:50 2011
@@ -1,4 +1,4 @@
-This software is copyright (c) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
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) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is Copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
This is free software, licensed under:
@@ -270,7 +270,7 @@
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is Copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
This is free software, licensed under:
Modified: trunk/liblist-utilsby-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/MANIFEST?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/MANIFEST (original)
+++ trunk/liblist-utilsby-perl/MANIFEST Tue Apr 26 08:29:50 2011
@@ -4,16 +4,21 @@
LICENSE
Makefile.PL
MANIFEST This list of files
+META.json
META.yml
README
t/00use.t
-t/01sortby.t
-t/02nsortby.t
-t/03maxby.t
-t/04minby.t
-t/05uniqby.t
-t/06partitionby.t
-t/07zipby.t
-t/08extract_by.t
+t/01sort_by.t
+t/02nsort_by.t
+t/03max_by.t
+t/04min_by.t
+t/05uniq_by.t
+t/06partition_by.t
+t/07count_by.t
+t/08zip_by.t
+t/09extract_by.t
+t/10weighted_shuffle_by.t
+t/11bundle_by.t
t/98back-compat.t
t/99pod.t
+t/TestRand.pm
Modified: trunk/liblist-utilsby-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/META.yml?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/META.yml (original)
+++ trunk/liblist-utilsby-perl/META.yml Tue Apr 26 08:29:50 2011
@@ -5,8 +5,9 @@
build_requires:
Test::More: 0
configure_requires:
- Module::Build: 0.36
-generated_by: 'Module::Build version 0.3607'
+ Module::Build: 0.38
+dynamic_config: 1
+generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.110930'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -15,7 +16,9 @@
provides:
List::UtilsBy:
file: lib/List/UtilsBy.pm
- version: 0.06
+ version: 0.07
+requires:
+ Exporter: 5.57
resources:
license: http://dev.perl.org/licenses/
-version: 0.06
+version: 0.07
Modified: trunk/liblist-utilsby-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/Makefile.PL?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/Makefile.PL (original)
+++ trunk/liblist-utilsby-perl/Makefile.PL Tue Apr 26 08:29:50 2011
@@ -1,10 +1,11 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.3607
+# Note: this file was auto-generated by Module::Build::Compat version 0.3800
use ExtUtils::MakeMaker;
WriteMakefile
(
'NAME' => 'List::UtilsBy',
'VERSION_FROM' => 'lib/List/UtilsBy.pm',
'PREREQ_PM' => {
+ 'Exporter' => '5.57',
'Test::More' => 0
},
'INSTALLDIRS' => 'site',
Modified: trunk/liblist-utilsby-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/README?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/README (original)
+++ trunk/liblist-utilsby-perl/README Tue Apr 26 08:29:50 2011
@@ -103,6 +103,17 @@
(such as numbers, or object references which overload stringification in
a suitable manner).
+ %counts = count_by { KEYFUNC } @vals
+ Returns a hash of integers, giving the number of times the key function
+ block returned a particular result, for each value in the list.
+
+ my %count_of_balls = count_by { $_->colour } @balls;
+
+ Because the values returned by the key function are used as hash keys,
+ they ought to either be strings, or at least well-behaved as strings
+ (such as numbers, or object references which overload stringification in
+ a suitable manner).
+
@vals = zip_by { ITEMFUNC } \@arr0, \@arr1, \@arr2,...
Returns a list of each of the values returned by the function block,
when invoked with values from across each each of the given ARRAY
@@ -161,6 +172,18 @@
will strengthen them all again.
+ @vals = weighted_shuffle_by { WEIGHTFUNC } @vals
+ 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
+ distributed with the distribution of the weights, and so on recursively
+ for the remaining items.
+
+ @vals = bundle_by { BLOCKFUNC } $number, @vals
+ Similar to a regular "map" functional, returns a list of the values
+ returned by "BLOCKFUNC". Values from the input list are given to the
+ block function in bundles of $number.
+
TODO
* XS implementations
Modified: trunk/liblist-utilsby-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/debian/changelog?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/debian/changelog (original)
+++ trunk/liblist-utilsby-perl/debian/changelog Tue Apr 26 08:29:50 2011
@@ -1,3 +1,11 @@
+liblist-utilsby-perl (0.07-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/copyright: Update license stanzas
+ * Bump Standards-Version to 3.9.2 (no changes)
+
+ -- Angel Abad <angelabad at gmail.com> Tue, 26 Apr 2011 10:29:15 +0200
+
liblist-utilsby-perl (0.06-1) unstable; urgency=low
* Initial Release. (Closes: #597624)
Modified: trunk/liblist-utilsby-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/debian/control?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/debian/control (original)
+++ trunk/liblist-utilsby-perl/debian/control Tue Apr 26 08:29:50 2011
@@ -2,10 +2,11 @@
Section: perl
Priority: optional
Build-Depends: debhelper (>= 7)
-Build-Depends-Indep: perl, libtest-pod-perl
+Build-Depends-Indep: libtest-pod-perl,
+ perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Angel Abad <angelabad at gmail.com>
-Standards-Version: 3.9.1
+Standards-Version: 3.9.2
Homepage: http://search.cpan.org/dist/List-UtilsBy/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/liblist-utilsby-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/liblist-utilsby-perl/
Modified: trunk/liblist-utilsby-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/debian/copyright?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/debian/copyright (original)
+++ trunk/liblist-utilsby-perl/debian/copyright Tue Apr 26 08:29:50 2011
@@ -8,15 +8,15 @@
License: Artistic or GPL-1+
Files: debian/*
-Copyright: 2010, Angel Abad <angelabad at gmail.com>
+Copyright: 2010-2011, Angel Abad <angelabad at gmail.com>
License: Artistic or GPL-1+
License: Artistic
This program is free software; you can redistribute it and/or modify
it under the terms of the Artistic License, which comes with Perl.
.
- On Debian GNU/Linux systems, the complete text of the Artistic License
- can be found in `/usr/share/common-licenses/Artistic'.
+ On Debian systems, the complete text of the Artistic License can be
+ found in `/usr/share/common-licenses/Artistic'.
License: GPL-1+
This program is free software; you can redistribute it and/or modify
@@ -24,5 +24,5 @@
the Free Software Foundation; either version 1, or (at your option)
any later version.
.
- On Debian GNU/Linux systems, the complete text of version 1 of the
- General Public License can be found in `/usr/share/common-licenses/GPL-1'.
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.
Modified: trunk/liblist-utilsby-perl/lib/List/UtilsBy.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/lib/List/UtilsBy.pm?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/lib/List/UtilsBy.pm (original)
+++ trunk/liblist-utilsby-perl/lib/List/UtilsBy.pm Tue Apr 26 08:29:50 2011
@@ -1,14 +1,14 @@
# 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,2010 -- leonerd at leonerd.org.uk
+# (C) Paul Evans, 2009-2011 -- leonerd at leonerd.org.uk
package List::UtilsBy;
use strict;
use warnings;
-our $VERSION = '0.06';
+our $VERSION = '0.07';
use Exporter 'import';
@@ -24,10 +24,15 @@
uniq_by
partition_by
+ count_by
zip_by
extract_by
+
+ weighted_shuffle_by
+
+ bundle_by
);
# Back-compat for old names of these functions.
@@ -280,6 +285,30 @@
return %parts;
}
+=head2 %counts = count_by { KEYFUNC } @vals
+
+Returns a hash of integers, giving the number of times the key function block
+returned a particular result, for each value in the list.
+
+ my %count_of_balls = count_by { $_->colour } @balls;
+
+Because the values returned by the key function are used as hash keys, they
+ought to either be strings, or at least well-behaved as strings (such as
+numbers, or object references which overload stringification in a suitable
+manner).
+
+=cut
+
+sub count_by(&@)
+{
+ my $code = shift;
+
+ my %counts;
+ $counts{ $code->( local $_ = $_ ) }++ for @_;
+
+ return %counts;
+}
+
=head2 @vals = zip_by { ITEMFUNC } \@arr0, \@arr1, \@arr2,...
Returns a list of each of the values returned by the function block, when
@@ -373,8 +402,59 @@
return @ret;
}
-# Keep perl happy; keep Britain tidy
-1;
+=head2 @vals = weighted_shuffle_by { WEIGHTFUNC } @vals
+
+Returns the list of values shuffled into a random order. The randomisation is
+not uniform, but weighted by the value returned by the C<WEIGHTFUNC>. The
+probabilty of each item being returned first will be distributed with the
+distribution of the weights, and so on recursively for the remaining items.
+
+=cut
+
+sub weighted_shuffle_by(&@)
+{
+ my $code = shift;
+ my @vals = @_;
+
+ my @weights = map { $code->( local $_ = $_ ) } @vals;
+
+ my @ret;
+ while( @vals > 1 ) {
+ my $total = 0; $total += $_ for @weights;
+ my $select = int rand $total;
+ my $idx = 0;
+ while( $select >= $weights[$idx] ) {
+ $select -= $weights[$idx++];
+ }
+
+ push @ret, splice @vals, $idx, 1, ();
+ splice @weights, $idx, 1, ();
+ }
+
+ push @ret, @vals if @vals;
+
+ return @ret;
+}
+
+=head2 @vals = bundle_by { BLOCKFUNC } $number, @vals
+
+Similar to a regular C<map> functional, returns a list of the values returned
+by C<BLOCKFUNC>. Values from the input list are given to the block function in
+bundles of C<$number>.
+
+=cut
+
+sub bundle_by(&@)
+{
+ my $code = shift;
+ my $n = shift;
+
+ my $n_1 = $n - 1;
+
+ map {
+ $code->( @_[$_*$n .. $_*$n+$n_1] )
+ } 0 .. $#_/$n;
+}
=head1 TODO
@@ -401,3 +481,7 @@
=head1 AUTHOR
Paul Evans <leonerd at leonerd.org.uk>
+
+=cut
+
+0x55AA;
Modified: trunk/liblist-utilsby-perl/t/98back-compat.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/t/98back-compat.t?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/t/98back-compat.t (original)
+++ trunk/liblist-utilsby-perl/t/98back-compat.t Tue Apr 26 08:29:50 2011
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
+use warnings;
use Test::More tests => 2;
Modified: trunk/liblist-utilsby-perl/t/99pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblist-utilsby-perl/t/99pod.t?rev=73594&op=diff
==============================================================================
--- trunk/liblist-utilsby-perl/t/99pod.t (original)
+++ trunk/liblist-utilsby-perl/t/99pod.t Tue Apr 26 08:29:50 2011
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use Test::More;
More information about the Pkg-perl-cvs-commits
mailing list