2,875
edits
No edit summary |
No edit summary |
||
Line 142: | Line 142: | ||
end | end | ||
-- Returns the maximum value in a sequence of values. | |||
function funlist:max() | |||
local h = funlist:first() | |||
for _, v in pairs(mytable) do | |||
local num = tonumber(v) | |||
if num == nil then error('Value is NaN') end | |||
if v > h then h = v end | |||
end | |||
return h | |||
end | |||
-- Returns the minimum value in a sequence of values. | |||
function funlist:min() | |||
local l = funlist:first() | |||
for _, v in pairs(mytable) do | |||
local num = tonumber(v) | |||
if num == nil then error('Value is NaN') end | |||
if v < l then l = v end | |||
end | |||
return l | |||
end | |||
return self | return self | ||
end | end |
edits