Algorithm-Voting
view release on metacpan or search on metacpan
lib/Algorithm/Voting/Sortition.pm view on Meta::CPAN
# $Id: Sortition.pm 60 2008-09-02 12:11:49Z johntrammell $
# $URL: https://algorithm-voting.googlecode.com/svn/tags/rel-0.01-1/lib/Algorithm/Voting/Sortition.pm $
package Algorithm::Voting::Sortition;
use strict;
use warnings;
use Scalar::Util qw/reftype looks_like_number/;
use Digest::MD5;
use Math::BigInt;
use Params::Validate 'validate';
use base 'Class::Accessor::Fast';
=pod
=head1 NAME
Algorithm::Voting::Sortition - implements RFC 3797, "Publicly Verifiable
lib/Algorithm/Voting/Sortition.pm view on Meta::CPAN
}
else {
return "$thing.";
}
}
=head2 $class->_sort(@items)
Returns a list containing the values of C<@items>, but sorted. Sorts
numerically if C<@items> contains only numbers (according to
C<Scalar::Util::looks_like_number()>), otherwise sorts lexically.
=cut
sub _sort {
my ($class, @items) = @_;
if (grep { !looks_like_number($_) } @items) {
return sort @items;
}
else {
return sort { $a <=> $b } @items;
}
}
=head2 $obj->digest($n)
Calculates and returns the I<n>th digest of the current keystring. This is
( run in 0.498 second using v1.01-cache-2.11-cpan-64827b87656 )