From cfe5f4fa7750619b5ce309464c2fb52584172133 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 27 Aug 2020 14:45:03 +0200 Subject: [PATCH] Add --cache option to factors script --- bin/factors | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/factors b/bin/factors index b6f72a9..8656277 100755 --- a/bin/factors +++ b/bin/factors @@ -7,10 +7,19 @@ local arrr = require 'arrr' local parser = arrr { { "Enable batch factorization", "--batch", "-b" }; { "Initialize prime table up to the Nth prime", "--initialize", "-n", "n", tonumber }; + { "Cache file", "--cache", "-c", 1, io.open }; } 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 for i=1, options.initialize do local _ = primes[i]