mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Add table.rope_len for determining length
This commit is contained in:
parent
7346d27e79
commit
b3703ab91d
10
table.lua
10
table.lua
@ -46,6 +46,16 @@ function rope(table)
|
||||
return setmetatable(table or {}, rope_metatable)
|
||||
end
|
||||
|
||||
local rope_len_metatable = {__index = {
|
||||
write = function(self, text)
|
||||
self.len = self.len + text:len()
|
||||
end
|
||||
}}
|
||||
--> rope for determining length supporting :write(text), .len being the length
|
||||
function rope_len(len)
|
||||
return setmetatable({len = len or 0}, rope_len_metatable)
|
||||
end
|
||||
|
||||
function is_circular(table)
|
||||
assert(type(table) == "table")
|
||||
local known = {}
|
||||
|
Loading…
Reference in New Issue
Block a user