10,731
edits
No edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
Line 37: | Line 37: | ||
if language.lineage == nil then return false end | if language.lineage == nil then return false end | ||
return language.lineage[code] ~= nil | return language.lineage[code] ~= nil | ||
end | |||
function export.distance(a, b) | |||
a, b = export.get_by_code(a), export.get_by_code(b) | |||
local i = 0 | |||
local count = 0 | |||
if a.lineage == nil or b.lineage == nil then return nil end | |||
for ancestor, _ in pairs(a.lineage) do | |||
count = count + 1 | |||
if b.lineage[ancestor] then i = i + 1 end | |||
end | |||
if i > 0 then return count - i else return nil end | |||
end | end | ||