From b8560d7e627513744ea12274e970d7bb3e664095 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 9 Sep 2022 21:24:20 +0200 Subject: [PATCH] Add func.compose --- func.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/func.lua b/func.lua index a2c1a54..095f725 100644 --- a/func.lua +++ b/func.lua @@ -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(...)