mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
Add func.compose
This commit is contained in:
parent
cc63bf33ca
commit
b8560d7e62
10
func.lua
10
func.lua
@ -8,6 +8,10 @@ setfenv(1, _ENV)
|
|||||||
|
|
||||||
no_op = function() end
|
no_op = function() end
|
||||||
|
|
||||||
|
-- TODO fix this being ugly AF
|
||||||
|
|
||||||
|
-- TODO switch all of these to vargs
|
||||||
|
|
||||||
function curry(func, ...)
|
function curry(func, ...)
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
return function(...) return func(unpack(args), ...) end
|
return function(...) return func(unpack(args), ...) end
|
||||||
@ -49,6 +53,12 @@ function memoize(func)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function compose(func, other_func)
|
||||||
|
return function(...)
|
||||||
|
return func(other_func(...))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function override_chain(func, override)
|
function override_chain(func, override)
|
||||||
return function(...)
|
return function(...)
|
||||||
func(...)
|
func(...)
|
||||||
|
Loading…
Reference in New Issue
Block a user