local function splitString(inputstr, sep) if sep == nil then sep = "%s" end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, str) end return t end local function filter(tableIn, predicate) local out = {} for _, val in ipairs(tableIn) do if predicate(val) then table.insert(out, val) end end return out end local function clamp(x, min, max) if x < min then x = min end if x > max then x = max end return x end local function round(num) return num + (2^52 + 2^51) - (2^52 + 2^51) end local function sign(x) return ( (x > 0) and 1 or (x < 0) and -1 or 0 ) end local function roundToZero(x) if x < 0 then return math.ceil(x) elseif x > 0 then return math.floor(x) else return 0 end end local function areaOverlap(x, y, areaX, areaY, areaW, areaH) return x > areaX and y > areaY and x < areaX + areaW and y < areaY + areaH end local function lerp(x, x0, y0, x1, y1) return y0 + (x - x0) * (y1 - y0) / (x1 - x0) end return { splitString = splitString, filter = filter, clamp = clamp, round = round, sign = sign, roundToZero = roundToZero, areaOverlap = areaOverlap, lerp = lerp }