From 24bcc78616427667afa7413221823df6b899d878 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Fri, 5 Mar 2021 12:07:28 +1100 Subject: [PATCH] [added] `tablex.append_inplace` and `tablex.append` can both take variable numbers of tables --- tablex.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tablex.lua b/tablex.lua index 5f38da2..6bc98d7 100644 --- a/tablex.lua +++ b/tablex.lua @@ -182,18 +182,20 @@ function tablex.values(t) end --append sequence t2 into t1, modifying t1 -function tablex.append_inplace(t1, t2) +function tablex.append_inplace(t1, t2, ...) for i,v in ipairs(t2) do table.insert(t1, v) end + if ... then + return table.append_inplace(t1, ...) + end return t1 end --return a new sequence with the elements of both t1 and t2 -function tablex.append(t1, t2) +function tablex.append(t1, ...) local r = {} - tablex.append_inplace(r, t1) - tablex.append_inplace(r, t2) + tablex.append_inplace(r, t1, ...) return r end