From 0215aa5b42cd1bba1535b7ba1e6eca13a2eff9ea Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 15 Apr 2009 10:46:34 +0200 Subject: [PATCH] awful.util: add table.concat() Signed-off-by: Julien Danjou --- lib/awful/util.lua.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index 97c9eb8f..1a24068c 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -14,6 +14,7 @@ local debug = debug local print = print local type = type local rtable = table +local ipairs = ipairs local capi = { awesome = awesome, @@ -23,6 +24,8 @@ local capi = --- Utility module for awful module("awful.util") +table = {} + function deprecate(see) io.stderr:write("W: awful: function is deprecated") if see then @@ -214,4 +217,21 @@ function subsets(set) return ret end +--- Concat all tables given as parameters. +-- This will iterate both tables and insert value from 1 to N. +-- Non integer keys are ignored. +-- @param t1 First table. +-- @param t2 Second table. +-- @return A new table with t1 and t2 concatened. +function table.concat(t1, t2) + local ret = {} + for k, v in ipairs(t1) do + ret[#ret + 1] = v + end + for k, v in ipairs(t2) do + ret[#ret + 1] = v + end + return ret +end + -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80