Differenze tra le versioni di "Modulo:Wikilib"

nessun oggetto della modifica
(Correzione errori *** sovrascritto il testo esistente ***)
w.interp = function(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
end
 
-- Aggiunge gli zeri a sinistra ai numeri con meno di tre cifre:
-- dato che valori numerici di questo tipo non sono supportati,
-- la funzione restituisce stringhe
 
w.three_figures = function(n)
if n < 10 then
return '00' .. n
elseif n < 100 then
return '0' .. n
else
return tostring(n)
end
end
 
w.linear_search = function(tab, value)
for a, b in pairs(tab) do
if b == value then
return true
end
end
return false