Anonymous user
simplify using a new binary_fold function, per protected edit request by User:Esquivalience
en>Mr. Stradivarius (get #expr without a frame, don't make unnecessary wrappers, and lazily initialise dependent modules, per protected edit request by User:Jackmcbarn) |
(simplify using a new binary_fold function, per protected edit request by User:Esquivalience) |
||
Line 49:
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.
Line 63:
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 190 ⟶ 198:
return result
end
--[[
Line 207 ⟶ 216:
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 239 ⟶ 241:
function p._min(...)
local min_value = binary_fold((function(a, b) return a < b end), ...)
if min_value then
return min_value
Line 270 ⟶ 265:
function p._average(...)
local
▲ return a + b
if not sum then
return 0
Line 362 ⟶ 354:
return oldr
end
local result, count =
return result
end
|