summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua/util.lua
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-27 17:11:41 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-27 17:11:41 +0000
commit5969571c6c69d2033ae341f0018b6d5836dc36ff (patch)
tree95368378293af5de7ad6b6749b5626f22771ddde /crawl-ref/source/dat/clua/util.lua
parenta6513eb40f637c25a695861eabffcecb29ade1e6 (diff)
downloadcrawl-ref-5969571c6c69d2033ae341f0018b6d5836dc36ff.tar.gz
crawl-ref-5969571c6c69d2033ae341f0018b6d5836dc36ff.zip
ziggurat ellipse builder (dpeg), needs work.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7657 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dat/clua/util.lua')
-rw-r--r--crawl-ref/source/dat/clua/util.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua
index c001be55bc..adefaa3439 100644
--- a/crawl-ref/source/dat/clua/util.lua
+++ b/crawl-ref/source/dat/clua/util.lua
@@ -18,6 +18,36 @@ function util.identity(x)
return x
end
+-- Returns a list of the keys in the given map.
+function util.keys(map)
+ local keys = { }
+ for key, _ in pairs(ziggurat_builder_map) do
+ table.insert(keys, key)
+ end
+ return keys
+end
+
+-- Returns a list of the values in the given map.
+function util.values(map)
+ local values = { }
+ for _, value in pairs(ziggurat_builder_map) do
+ table.insert(values, value)
+ end
+ return values
+end
+
+-- Creates a string of the elements in list joined by separator.
+function util.join(sep, list)
+ local res = ""
+ for i, val in ipairs(list) do
+ if i > 1 then
+ res = res .. sep
+ end
+ res = res .. val
+ end
+ return res
+end
+
-- Creates a set (a map of keys to true) from the list supplied.
function util.set(list)
local set = { }