Add func.compose

This commit is contained in:
Lars Mueller 2022-09-09 21:24:20 +02:00
parent cc63bf33ca
commit b8560d7e62

@ -8,6 +8,10 @@ setfenv(1, _ENV)
no_op = function() end
-- TODO fix this being ugly AF
-- TODO switch all of these to vargs
function curry(func, ...)
local args = { ... }
return function(...) return func(unpack(args), ...) end
@ -49,6 +53,12 @@ function memoize(func)
})
end
function compose(func, other_func)
return function(...)
return func(other_func(...))
end
end
function override_chain(func, override)
return function(...)
func(...)