diff options
author | Marius <mariausol@gmail.com> | 2011-06-20 16:50:10 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-06-20 16:50:10 +0300 |
commit | 06465c8428905be5c083c70f4e7de6a59d129139 (patch) | |
tree | 4141cc479a1d8dfc991e3aa04d62a31752bfdec0 /tex/context/base/l-table.lua | |
parent | a12c76dbfcdf2a4159ba03613ba990a57b9b1ce0 (diff) | |
download | context-06465c8428905be5c083c70f4e7de6a59d129139.tar.gz |
beta 2011.06.19 14:17
Diffstat (limited to 'tex/context/base/l-table.lua')
-rw-r--r-- | tex/context/base/l-table.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua index eeb3f47f6..d651608ae 100644 --- a/tex/context/base/l-table.lua +++ b/tex/context/base/l-table.lua @@ -15,7 +15,7 @@ local getinfo = debug.getinfo -- Starting with version 5.2 Lua no longer provide ipairs, which makes -- sense. As we already used the for loop and # in most places the -- impact on ConTeXt was not that large; the remaining ipairs already --- have been replaced. In a similar fashio we also hardly used pairs. +-- have been replaced. In a similar fashion we also hardly used pairs. -- -- Just in case, we provide the fallbacks as discussed in Programming -- in Lua (http://www.lua.org/pil/7.3.html): @@ -939,3 +939,20 @@ function table.loweredkeys(t) -- maybe utf end return l end + +-- new, might move (maybe duplicate) + +function table.unique(old) + local hash = { } + local new = { } + local n = 0 + for i=1,#old do + local oi = old[i] + if not hash[oi] then + n = n + 1 + new[n] = oi + hash[oi] = true + end + end + return new +end |