Module:MOS: Difference between revisions

Inthar (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Inthar (talk | contribs)
I was very dumb.
Line 3: Line 3:
local et = require('Module:ET')
local et = require('Module:ET')
local p = {}
local p = {}
local function abs(x)
if x >= 0 then
return x
else
return -x
end
end


p.tamnams_name = { -- Only mosses with 2/1-equave names in TAMNAMS
p.tamnams_name = { -- Only mosses with 2/1-equave names in TAMNAMS
Line 142: Line 150:
while current_nL > 1 or current_ns > 1 do -- while current mos is not 1L 1s<equave>, record current mos and go up to parent
while current_nL > 1 or current_ns > 1 do -- while current mos is not 1L 1s<equave>, record current mos and go up to parent
table.insert(path_to_root, {[1] = current_nL, [2] = current_ns})
table.insert(path_to_root, {[1] = current_nL, [2] = current_ns})
current_nL, current_ns = math.min(current_nL, current_ns), math.max(current_nL, current_ns)-math.min(current_nL, current_ns) -- parent's nL and ns
current_nL, current_ns = math.min(current_nL, current_ns), abs(current_nL - current_ns) -- parent's nL and ns
end
end
local len_of_path = table.getn(path_to_root)
local len_of_path = table.getn(path_to_root)
Line 170: Line 178:
while current_nL > 1 or current_ns > 1 do -- while current mos is not 1L 1s, record current mos and go up to parent
while current_nL > 1 or current_ns > 1 do -- while current mos is not 1L 1s, record current mos and go up to parent
table.insert(path_to_root, {[1] = current_nL, [2] = current_ns})
table.insert(path_to_root, {[1] = current_nL, [2] = current_ns})
current_nL, current_ns = math.min(current_nL, current_ns), math.max(current_nL, current_ns)-math.min(current_nL, current_ns)
current_nL, current_ns = math.min(current_nL, current_ns), abs(current_nL - current_ns)
end
end
local len_of_path = table.getn(path_to_root)
local len_of_path = table.getn(path_to_root)