summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-01 09:56:07 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-01 09:56:07 +0100
commitf7eee862b8d364edea6f20ccb2dd6fc18d8b5a01 (patch)
treec19c65f997534b87f11b76522baa36b3c2f24b2b
parent6dddaac927d3199ac13a5cf0dc7a704bb5db720c (diff)
downloadgitano-f7eee862b8d364edea6f20ccb2dd6fc18d8b5a01.tar.gz
UTIL: Add a set utility function for turning ipairs() tables into sets
-rw-r--r--lib/gitano/util.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua
index cfab64d..b0ca710 100644
--- a/lib/gitano/util.lua
+++ b/lib/gitano/util.lua
@@ -249,6 +249,15 @@ local function process_expansion(tags, expn, tagsactive)
return tconcat(r)
end
+local function set(t)
+ local ret = {}
+ for i, v in ipairs(t) do
+ ret[i] = v
+ ret[v] = i
+ end
+ return ret
+end
+
return {
parse_cmdline = _parse_cmdline,
@@ -266,4 +275,6 @@ return {
prep_expansion = prep_expansion,
process_expansion = process_expansion,
+
+ set = set,
}