1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- function table.pos(t, k)
- local ret = nil
- for i,n in ipairs(t) do
- if n == k then
- ret = i
- break
- end
- end
- return ret
- end
- function table.keypos(t, p)
- local ret
- for i,n in ipairs(t) do
- if i == p then
- ret = n
- break
- end
- end
- return ret
- end
- function table.keyfirst(t)
- return table.keypos(t, 1)
- end
- function table.keylast(t)
- return table.keypos(t, table.getn(t))
- end
- function string.trim(s)
-
- return (s:gsub("^%s*(.-)%s*$", "%1"))
- end
|