summaryrefslogtreecommitdiff
path: root/tex/context/base/l-set.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/l-set.lua')
-rw-r--r--tex/context/base/l-set.lua87
1 files changed, 42 insertions, 45 deletions
diff --git a/tex/context/base/l-set.lua b/tex/context/base/l-set.lua
index 2bcf664f8..199253ee2 100644
--- a/tex/context/base/l-set.lua
+++ b/tex/context/base/l-set.lua
@@ -1,59 +1,56 @@
--- filename : l-set.lua
--- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
--- copyright: PRAGMA ADE / ConTeXt Development Team
--- license : see context related readme files
+if not modules then modules = { } end modules ['l-set'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
-if not versions then versions = { } end versions['l-set'] = 1.001
+set = set or { }
-if not set then set = { } end
+local nums = { }
+local tabs = { }
+local concat = table.concat
-do
+set.create = table.tohash
- local nums = { }
- local tabs = { }
- local concat = table.concat
-
- set.create = table.tohash
-
- function set.tonumber(t)
- if next(t) then
- local s = ""
- -- we could save mem by sorting, but it slows down
- for k, v in pairs(t) do
- if v then
- -- why bother about the leading space
- s = s .. " " .. k
- end
- end
- if not nums[s] then
- tabs[#tabs+1] = t
- nums[s] = #tabs
+function set.tonumber(t)
+ if next(t) then
+ local s = ""
+ -- we could save mem by sorting, but it slows down
+ for k, v in pairs(t) do
+ if v then
+ -- why bother about the leading space
+ s = s .. " " .. k
end
- return nums[s]
- else
- return 0
end
- end
-
- function set.totable(n)
- if n == 0 then
- return { }
- else
- return tabs[n] or { }
+ if not nums[s] then
+ tabs[#tabs+1] = t
+ nums[s] = #tabs
end
+ return nums[s]
+ else
+ return 0
end
+end
- function set.contains(n,s)
- if type(n) == "table" then
- return n[s]
- elseif n == 0 then
- return false
- else
- local t = tabs[n]
- return t and t[s]
- end
+function set.totable(n)
+ if n == 0 then
+ return { }
+ else
+ return tabs[n] or { }
end
+end
+function set.contains(n,s)
+ if type(n) == "table" then
+ return n[s]
+ elseif n == 0 then
+ return false
+ else
+ local t = tabs[n]
+ return t and t[s]
+ end
end
--~ local c = set.create{'aap','noot','mies'}