mirror of
https://github.com/appgurueu/modlib.git
synced 2025-02-17 00:32:35 +01:00
Add func.compose
This commit is contained in:
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(...)
|
||||||
|
Reference in New Issue
Block a user