Module:Mediants: Difference between revisions

Ganaram inukshuk (talk | contribs)
todo
Ganaram inukshuk (talk | contribs)
Add deepest_depth function
Line 2: Line 2:


-- TODO:
-- TODO:
-- - Redefine mediant-search functions to return the deepest depth. Meant for
--  use with making tables. (Instead of ratios and depths, it's ratios, depths,
--  and deepest_depth.) Existing function calls will work the same as before,
--  and modules making a table can use this accordingly. ALT IMPLEMENTATION:
--  a helper function that returns the deepest depth, when a table of depths is
--  passed in.
-- - Add a convert-to-rational function.
-- - Add a convert-to-rational function.
--------------------------------------------------------------------------------
------------------------------ UTILITY FUNCTIONS -------------------------------
--------------------------------------------------------------------------------
-- Given a table of depths, return the deepest depth
function p.deepest_depth(depths)
local deepest = nil
for _, value in ipairs(depths) do
if not deepest or value > deepest then
deepest = value
end
end
return deepest
end


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------