Module:SB tree: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
No edit summary
Line 6: Line 6:
-- Start and stop ratio may be any two ratios, but the default values are 1/1 and 1/0
-- Start and stop ratio may be any two ratios, but the default values are 1/1 and 1/0
-- Depth may be specified to be any value, but the default is 4; this is how many generations
-- Depth may be specified to be any value, but the default is 4; this is how many generations
-- after the initial ratios to produce successive layers of the tree
-- after the initial ratios to produce successive layers of the tree, so depth 4 is 5 layers
-- Edge extend iteratively finds the mediants of the first two and last two ratios; default is 0
-- Edge extend iteratively finds the mediants of the first two and last two ratios; default is 0
-- Transpiled from python code to lua with aid of ChatGPT
-- Transpiled from python code to lua with aid of ChatGPT
Line 64: Line 64:
-- This is nearly identical to the sb_tree_ratios function, except only the depth
-- This is nearly identical to the sb_tree_ratios function, except only the depth
-- and edge extend are needed
-- and edge extend are needed
-- Transpiled from python code to lua with aid of ChatGPT
-- Depths start at 1 rather than 0, for lua code purposes
-- Depths start at 1 rather than 0, for lua code purposes
function p.sb_tree_depths(depth, edge_extend)
function p.sb_tree_depths(depth, edge_extend)
Line 77: Line 78:
         local new_tree = {}
         local new_tree = {}


-- Depths of the first and mediant of first and second ratio are added in pairs
-- The last ratio is added after the for loop itself
         for j = 1, #tree - 1 do
         for j = 1, #tree - 1 do
             local depth_1 = tree[j]
             local depth_1 = tree[j]
Line 90: Line 93:


     -- For extending the edges of the tree
     -- For extending the edges of the tree
    -- When edge-extending, the first and last depths must always be 1
     for i = 1, edge_extend do
     for i = 1, edge_extend do
         -- Extend at end
         -- Extend at end
Line 103: Line 107:
end
end


-- TODO: Add depths to create the staggered look of the SB tree, typical of nearly all scale tree pages
-- Test function that produces the ratios of the SB tree as a multi-column table, using different arguments
-- Test function that produces the ratios of the SB tree as a one-column table, using different arguments
-- To try this out, add the following text (not as a lua comment):
-- To try this out, add the following text (not as a lua comment):
-- {{#invoke:SB_tree|sb_table}}
-- {{#invoke:SB_tree|sb_table}}