diff options
author | Karl Berry <karl@freefriends.org> | 2012-08-13 22:41:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-08-13 22:41:51 +0000 |
commit | 891d790aa1dafff5340c181e3dce3332526e4834 (patch) | |
tree | 049abb04059bc666a0ffa9c585547f5fee297a4c /Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua | |
parent | 99f6ebc940e504927ea38d6600f8ca9f893667bb (diff) |
new luatex package luaxml (13aug12)
git-svn-id: svn://tug.org/texlive/trunk@27394 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua new file mode 100644 index 00000000000..54386ff84d3 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-stack.lua @@ -0,0 +1,63 @@ +-- Code from http://lua-users.org/wiki/SimpleStack +module(...,package.seeall) +Stack = {} + +-- Create a Table with stack functions +function Stack:Create() + + -- stack table + local t = {} + -- entry table + t._et = {} + + -- push a value on to the stack + function t:push(...) + if ... then + local targs = {...} + -- add values + for _,v in pairs(targs) do + table.insert(self._et, v) + end + end + end + + -- pop a value from the stack + function t:pop(num) + + -- get num values from stack + local num = num or 1 + + -- return table + local entries = {} + + -- get values into entries + for i = 1, num do + -- get last entry + if #self._et ~= 0 then + table.insert(entries, self._et[#self._et]) + -- remove last value + table.remove(self._et) + else + break + end + end + -- return unpacked entries + return unpack(entries) + end + + -- get entries + function t:getn() + return #self._et + end + + -- list values + function t:list() + for i,v in pairs(self._et) do + print(i, v) + end + end + function t:join(s) + return table.concat(self._et,s) + end + return t +end |