summaryrefslogtreecommitdiff
path: root/tex/context/base/l-table.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-10-18 15:20:00 +0200
committerHans Hagen <pragma@wxs.nl>2009-10-18 15:20:00 +0200
commitea36ada779b87db193b865429d5db510713038a4 (patch)
tree29457e3c7ee61f0c6e6023bfb50f473ea9c54a5e /tex/context/base/l-table.lua
parent7f9b179ad5be5000f67192f283d20e7120402bd9 (diff)
downloadcontext-ea36ada779b87db193b865429d5db510713038a4.tar.gz
beta 2009.10.18 15:20
Diffstat (limited to 'tex/context/base/l-table.lua')
-rw-r--r--tex/context/base/l-table.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 9e0b12f7c..d7c2b0250 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -614,7 +614,7 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
end
end
-local function flatten(t,f,complete)
+local function flatten(t,f,complete) -- is this used? meybe a variant with next, ...
for i=1,#t do
local v = t[i]
if type(v) == "table" then
@@ -643,6 +643,24 @@ end
table.flatten_one_level = table.unnest
+-- a better one:
+
+local function flattened(t,f)
+ if not f then
+ f = { }
+ end
+ for k, v in next, t do
+ if type(v) == "table" then
+ flattened(v,f)
+ else
+ f[k] = v
+ end
+ end
+ return f
+end
+
+table.flattened = flattened
+
-- the next three may disappear
function table.remove_value(t,value) -- todo: n