Module:Limits: Difference between revisions

Plumtree (talk | contribs)
m Refactoring
Plumtree (talk | contribs)
m Distinct consistency limit optimisation
Line 61: Line 61:
approx_set[a_approx] = true
approx_set[a_approx] = true
end
end
end
if type(distinct) == 'number' then
return true
end
end
local previous_ordered = {}
local previous_ordered = {}
Line 113: Line 116:
-- returns nil when at least `max_n`
-- returns nil when at least `max_n`
-- `distinct`: whether distinct ratios are required to be mapped to distinct approximations
-- `distinct`: whether distinct ratios are required to be mapped to distinct approximations
-- - if an integer, it is the regular consistency limit already known
function p.consistency_limit(et, distinct, max_n)
function p.consistency_limit(et, distinct, max_n)
if et.size == 0 then
if et.size == 0 then
Line 124: Line 128:
local previous = {}
local previous = {}
while true do
while true do
if type(distinct) == 'number' and n > distinct then
return last_n
end
local ratios = p.limit_modulo_equave(n, et.equave, previous)
local ratios = p.limit_modulo_equave(n, et.equave, previous)
for key, ratio in pairs(ratios) do
for key, ratio in pairs(ratios) do