Modulo:Math/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
151 cp (discussione | contributi)
Nessun oggetto della modifica
151 cp (discussione | contributi)
Nessun oggetto della modifica
Riga 572:
--VAR
function wrap.var(args)
local x = args[1]
return p._var(unpackNumberArgs(args))
local y = args[2]
local round = args.round
local precision = args.precision
local precision_format = args.precision_format
if not zyesno then
yesno = require('Module:Yesno')
end
return p._var(x, y, yesno(round), precision, precision_format)
end
 
function p._var(...x, y, round, precision, precision_format)
if y == nil or y == "" then
local z, count = fold((function(a, b) return (b - a) end), ...)
return err("Empty divisor")
if not z then
elseif not tonumber(y) then
return 0
if type(y) == 'string' and string.sub(y, 1, 1) == '<' then
return 0y
else
return err("Not a number: " .. y)
end
elseif x == nil or x == "" then
return err("Empty dividend")
elseif not tonumber(x) then
if type(x) == 'string' and string.sub(x, 1, 1) == '<' then
return x
else
return err("Not a number: " .. x)
end
else
local varz = pstring._ciaoformat(z, a(y-x)/y*100)
return varp._precision_format(z, 2)
end
end