forked from pyrex/chameleonic
tostring golf
this could be golfed further by rewriting the str..= line in terms of fmt, but the performance impact of inserting the extra `fmt` calls and parsing into the tostring recursion seems likely to be a problem.
This commit is contained in:
parent
e6c35dbeda
commit
f86e52d3bd
@ -279,14 +279,12 @@ function kbd:release(i)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function tostring(any)
|
function tostring(any)
|
||||||
if type(any)=="table" then
|
if (type(any)!="table") return tostr(any)
|
||||||
local str = "{ "
|
local str = "{ "
|
||||||
for k,v in pairs(any) do
|
for k,v in pairs(any) do
|
||||||
str=str..tostring(k).."->"..tostring(v).." "
|
str..=tostring(k).."->"..tostring(v).." "
|
||||||
end
|
|
||||||
return str.."}"
|
|
||||||
end
|
end
|
||||||
return tostr(any)
|
return str.."}"
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
|
Loading…
Reference in New Issue
Block a user