Acme-ELLEDNERA-Utils
view release on metacpan or search on metacpan
lib/Acme/ELLEDNERA/Utils.pm view on Meta::CPAN
@shuffled = shuffle(@ori_nums);
=head1 EXPORT
None by default
=head1 SUBROUTINES
=head2 sum( LIST )
Obtains the sum of a list of numbers. If no numbers are passed in, it will return C<undef>.
A mixture of numbers and non-numerics will work too. However, complex and scientific
numbers are not supported.
The C<sum> subroutine in version 0.03 is broken
=head2 shuffle( LIST )
Shuffle a list of anything :) This subroutine uses the Fisher Yates Shuffle algorithm.
I just copied and pasted (most of) them from L<https://perldoc.perl.org/perlfaq4#How-do-I-shuffle-an-array-randomly?>
use strict;
use warnings;
use Test::More;
use Acme::ELLEDNERA::Utils "sum";
ok( defined &sum, "Acme::ELLEDNERA::Utils::sum export ok" );
is( sum(1, 2, 3), 6, "1+2+3 = 6");
is( sum(5, 5, 12, 9), 31, "5+5+12+9 = 31");
is( sum(1.2, 3.14159), 4.34159, "1.2+3.14159 = 4.34159");
is( sum( qw(t1 t2) ), undef, "Non-numeric shouldn't work :)");
is( sum( qw(t1 10 t2 5 6) ), 21, "Mixture only return sum of numerics (21)");
done_testing();
# besiyata d'shmaya
( run in 1.042 second using v1.01-cache-2.11-cpan-d80b1682f3f )