"ମଡ୍ୟୁଲ:Math" ପୃଷ୍ଠାର ସଂସ୍କରଣଗୁଡ଼ିକ ମଧ୍ୟରେ ତଫାତ
Content deleted Content added
ଟିକେ en:Module:Mathରୁ ୧ ଗୋଟି ସଂସ୍କରଣ ଅଣାଗଲା |
simplify using a new binary_fold function, per protected edit request by User:Esquivalience |
||
୪୯ କ ଧାଡ଼ି:
end
local function
-- Use a function on all supplied arguments, and return the result. The function must accept two numbers as parameters,
-- and must return a number as an output. This number is then supplied as input to the next function call.
୬୩ କ ଧାଡ଼ି:
end
return ret, count
--[[
Fold arguments by selectively choosing values (func should return when to choose the current "dominant" value).
]]
local value = fold((function(a, b) if func(a, b) then return a else return b end end), ...)
end
Line ୧୯୦ ⟶ ୧୯୮:
return result
end
--[[
Line ୨୦୭ ⟶ ୨୧୬:
function p._max(...)
local max_value = binary_fold((function(a, b) return a > b end), ...)
▲ local function maxOfTwo(a, b)
▲ end
if max_value then
return max_value
Line ୨୩୯ ⟶ ୨୪୧:
function p._min(...)
local min_value = binary_fold((function(a, b) return a < b end), ...)
if min_value then
return min_value
Line ୨୭୦ ⟶ ୨୬୫:
function p._average(...)
local
▲ return a + b
if not sum then
return 0
Line ୩୬୨ ⟶ ୩୫୪:
return oldr
end
local result, count =
return result
end
|