Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serfuns = {
- table = function(tbl, recur)
- local result = {}
- local intkeys, maxint = 0, 0
- for k, v in pairs(tbl) do
- if intkeys and type(k) == "number" then
- if (k > 0) and (k % 1 == 0) then
- intkeys = intkeys + 1
- if k > maxint then
- maxint = k
- end
- end
- else
- intkeys = false
- end
- table.insert(result, "["..anal(k, recur).."]="..anal(v, recur))
- end
- if maxint == intkeys then
- result = {}
- for i,v in ipairs(tbl) do
- table.insert(result, anal(v))
- end
- end
- return ("{"..table.concat(result,", ").."}")
- end,
- string = function(x) return string.format("%q", x) end,
- ["function"] = tostring,
- boolean = tostring,
- userdata = tostring
- }
- _G.anal = function (thing, recur)
- recur = recur or {}
- local serfun = serfuns[type(thing)]
- if not serfun then
- return thing
- end
- if recur[thing] then
- return "*** REKURZE ***"
- end
- if type(thing) == "table" then
- recur[thing] = true
- end
- return serfun(thing, recur)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement