From 5db6be936a3f9bb59c184715bfb75fbb2bdbdbce Mon Sep 17 00:00:00 2001 From: rxi Date: Thu, 3 Apr 2014 20:09:40 +0100 Subject: [PATCH] Added lume.combine() function --- lume.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lume.lua b/lume.lua index 2933bd9..2c6609a 100644 --- a/lume.lua +++ b/lume.lua @@ -31,6 +31,10 @@ local absindex = function(len, i) return i < 0 and (len + i + 1) or i end +local isfunction = function(x) + return type(x) == "function" +end + function lume.clamp(x, min, max) return x < min and min or (x > max and max or x) @@ -242,6 +246,15 @@ function lume.once(fn, ...) end +function lume.combine(...) + local funcs = {...} + assert(lume.all(funcs, isfunction), "expected all arguments to be functions") + return function(...) + for _, f in ipairs(funcs) do f(...) end + end +end + + function lume.time(fn, ...) local start = os.clock() local rtn = {fn(...)}