| Math-Prime-TiedArray documentation | view source | Contained in the Math-Prime-TiedArray distribution. |
Math::Prime::TiedArray - Simulate an infinite array of prime numbers
Version 0.04
use Math::Prime::TiedArray;
tie my @primes, "Math::Prime::TiedArray";
Allows access to an array of prime numbers, that will be extended as-needed:
use Math::Prime::TiedArray;
my @primes;
tie @primes, "Math::Prime::TiedArray";
# print the first 100 primes:
print join ", ", @primes[0..99];
# print the 200th prime:
print $primes[199];
# print all the primes smaller than 500
while ((my $prime = shift @primes) < 500) {
print "$prime, ";
}
Pre-calculate all primes smaller than 10,000:
my @primes;
tie @primes, "Math::Prime::TiedArray", precompute => 10_000;
Use a persistant cache:
my @primes;
tie @primes, "Math::Prime::TiedArray", cache => "/path/to/cache.dbm"
How many new primes should be calculated when the cache runs out.
Set a limit, triggering an exception (croak) if an attempt is made to find a prime larger than the ceiling.
Output debug messages:
0 - none
1 - progress updates for atkin
2 - prime calculations
3 - tie API
4 - internal progress for atkin
Dan Boger, <cpan at peeron.com>
Please report any bugs or feature requests to
bug-math-prime-tiedarray at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-Prime-TiedArray.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Math::Prime::TiedArray
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Prime-TiedArray
Copyright 2007 Dan Boger, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Math-Prime-TiedArray documentation | view source | Contained in the Math-Prime-TiedArray distribution. |