Jump to content

Module:Clade/sequential: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
create
(No difference)

Revision as of 08:41, 31 October 2019

local p = {}
local pargs 
function p.main(frame)

    pargs = frame:getParent().args
	
	local args = {}
	local i=1
	local contentString = ""
    local max = getMax()
 
    contentString  = p.clade(frame,1,max)
    
	return contentString 

end

function p.clade(frame,i,max)
	local args = {}
	
	args[1] = pargs [i]
	args['label1'] = pargs ['label'..tostring(i)] 
	if i+1 == max then 
		args[2] = pargs [i+1]
		args['label2'] = pargs ['label'..tostring(i+1)]	
	else
		args[2] = p.clade(frame,i+1,max)       -- or the result of the next pair
	end
	
	
	
	return frame:expandTemplate{ title = "Clade", args = args }
end

function getMax()
	local i=1
	local max
    while i<50 do
       	if  pargs [i] then 
       		max = i 
       		i=i+1
		else
       	    break
    	end
    end
    return max
end

return p