Module:Sandbox/Ajuanca/

-- Ajuanca Google Code-in 2019, Introduction to Lua in Wikipedia.

local p = {}

function p.hello( frame ) return "Hello, world!" end

p.Hi = function(frame) strName = frame.args.name or "Jimmy" end

function p.converttemp(frame) cels = tonumber(frame.args.celsius) or 0 fahr = (((cels * 9) / 5) + 32) kelvin = cels + 273.15 str = cels .. " degrees Celsius is " .. fahr .. " degrees Fahrenheit." str = str .. " That's the same as say " .. kelvin .. " Kelvin." if cels > 9 then str = str .. " It is warm." elseif cels < 9 then str = str .. " It is cold." else str = str .. " It isn't neither warm nor cold." end return str end

-- Task 4 -- Timestable function function p.timestable(frame) local random = math.random(-12, 12) local numb = tonumber( frame.args.numb ) or random local out = " The " .. numb .. " times table. " out = out .. "When no number is given or no parameter is sended, the default value is used. Instead of 2, the default number is generated randomly between -12 and 12, and in this case is " .. random .. ". "	for i = 1, 12 do out = out .. i .. " times " .. numb .. " equals " .. i * numb .. " "	end return out end

-- People function function p.people(frame) local friends = {"Agnetha", "Betty", "Carlos", "Davinder", "Eloise", "Martin", "Doug", "Diego"} local msg = "" for i = 1, #friends do msg = msg .. "Hello " .. friends[i] .. " "	end return msg end

function p.orgnanizeLanguages local allLanguages = mw.language.fetchLanguageNames local organizedLanguages = {} local maximun = 0 local minimu = 0 for k, v in pairs(allLanguages) do		for i = 1, table.getn(organizedLanguages)+1, 1 do			if i == 1 then maximun = 0 minimun = 0 end if table.getn(organizedLanguages) == 0 then table.insert(organizedLanguages, i, k)			elseif i == 1+table.getn(organizedLanguages) then for x = 0, table.getn(organizedLanguages), 1 do					if x minimun then table.insert(organizedLanguages, x, k)					end end else if table.getn(mw.language.getFallbacksFor(k)) < table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then if maximun > table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then maximun = i 					end elseif table.getn(mw.language.getFallbacksFor(k)) == table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then table.insert(organizedLanguages, i+1, k)				else if minimun < table.getn(mw.language.getFallbacksFor(organizedLanguages[i])) then minimun = i 					end end end end end local out = "" for d = 0, table.getn(organizedLanguages), 1 do out = out .. organizedLanguages[d] .. " - " .. table.getn(mw.language.getFallbacksFor(organizedLanguages[d])) .. " "	end return out end

return p