Add func.identity

This commit is contained in:
Lars Mueller 2022-09-30 16:09:16 +02:00
parent 8b538587ad
commit d72e589a62

@ -6,11 +6,11 @@ local modlib, unpack, select, setmetatable
local _ENV = {} local _ENV = {}
setfenv(1, _ENV) setfenv(1, _ENV)
no_op = function() end function no_op() end
-- TODO fix this being ugly AF function identity(...) return ... end
-- TODO switch all of these to vargs -- TODO switch all of these to proper vargs
function curry(func, ...) function curry(func, ...)
local args = { ... } local args = { ... }
@ -73,6 +73,8 @@ end
-- Functional wrappers for Lua's builtin metatable operators (arithmetic, concatenation, length, comparison, indexing, call) -- Functional wrappers for Lua's builtin metatable operators (arithmetic, concatenation, length, comparison, indexing, call)
-- TODO (?) add operator table `["+"] = add, ...`
function add(a, b) return a + b end function add(a, b) return a + b end
function sub(a, b) return a - b end function sub(a, b) return a - b end