Module:Mediants: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
mNo edit summary
Line 36: Line 36:
local ratios = {}
local ratios = {}
local depths = {}
local depths = {}
local filter_arg = depth
local filter_args = depth
local filter_func = p.search_depth_filter
local filter_func = p.search_depth_filter
ratios, depths = p.find_mediants_by_filter(init_ratios, filter_func, filter_arg)
ratios, depths = p.find_mediants_by_filter(init_ratios, filter_func, filter_args)
return ratios, depths
return ratios, depths
end
end
Line 45: Line 45:
-- Find mediants by filter, where the filter function and its args are passed in
-- Find mediants by filter, where the filter function and its args are passed in
-- as part of the function call.
-- as part of the function call.
function p.find_mediants_by_filter(init_ratios, filter, filter_arg)
function p.find_mediants_by_filter(init_ratios, filter_func, filter_args)
local init_ratios = init_ratios or {{1,1}, {1,0}}
local init_ratios = init_ratios or {{1,1}, {1,0}}
Line 72: Line 72:
table.insert(new_depths, depth_1)
table.insert(new_depths, depth_1)
if filter(mediant, new_depth, filter_arg) then
if filter_func(mediant, new_depth, filter_args) then
table.insert(new_ratios, mediant)
table.insert(new_ratios, mediant)
table.insert(new_depths, new_depth)
table.insert(new_depths, new_depth)