Add --cache option to factors script
This commit is contained in:
parent
4cc5d0ece9
commit
cfe5f4fa77
1 changed files with 9 additions and 0 deletions
|
@ -7,10 +7,19 @@ local arrr = require 'arrr'
|
||||||
local parser = arrr {
|
local parser = arrr {
|
||||||
{ "Enable batch factorization", "--batch", "-b" };
|
{ "Enable batch factorization", "--batch", "-b" };
|
||||||
{ "Initialize prime table up to the Nth prime", "--initialize", "-n", "n", tonumber };
|
{ "Initialize prime table up to the Nth prime", "--initialize", "-n", "n", tonumber };
|
||||||
|
{ "Cache file", "--cache", "-c", 1, io.open };
|
||||||
}
|
}
|
||||||
|
|
||||||
local options = parser {...}
|
local options = parser {...}
|
||||||
|
|
||||||
|
if options.cache then
|
||||||
|
local i = 1
|
||||||
|
for line in options.cache:lines() do
|
||||||
|
primes[i] = tonumber(line)
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if options.initialize then
|
if options.initialize then
|
||||||
for i=1, options.initialize do
|
for i=1, options.initialize do
|
||||||
local _ = primes[i]
|
local _ = primes[i]
|
||||||
|
|
Loading…
Reference in a new issue