|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/SortedKeys1.lua.html
-- http://anggtwu.net/LUA/SortedKeys1.lua
-- (find-angg "LUA/SortedKeys1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/SortedKeys1.lua"))
-- Used by: (find-es "lua5" "luasvgwriter")
SortedKeys = Class {
type = "SortedKeys",
from = function (T)
local keys = VTable {}
for i,kv in ipairs(Tos({}):getsortedkvs(T)) do
table.insert(keys, kv.key)
end
return SortedKeys {T=T, keys=keys}
end,
__tostring = function (sk) return sk:tostring1() end,
__index = {
tostring0 = function (sk) return tostring(sk.keys) end,
tostringf = function (sk, f) return tostring(DGetInfo.fromfunction(f)) end,
tostringv = function (sk, v)
if type(v) == "function" then return sk:tostringf(v) end
return " "..type(v)
end,
tostringk = function (sk, k)
return mytostring(k)
end,
tostring1 = function (sk)
local f = function (k)
return format("%-15s ->%s", sk:tostringk(k), sk:tostringv(sk.T[k]))
end
return mapconcat(f, sk.keys, "\n")
end,
},
}
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "SortedKeys1.lua"
= SortedKeys.from(Tos)
= SortedKeys.from(Tos.__index)
= SortedKeys.from(Tos.__index):tostring0()
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: