求最大值,最小值及长度: function maxn(t) local mn = nil for i, v in pairs(t) do if (mn==nil) then mn=v end if (mn<v) then mn=v end end return mn end function lenn(t) local leng=0 for i,v in pairs(t) do leng=leng+1 end return leng; end function minn(t) local min…
table.maxn (table) Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. (To do its job this function does a linear traversal of the whole table.) 返回表中最大的正数值index. 说明: 1. 此接口不是统计表中元素的…
为方便调试lua程序,往往想以树的形式打印出一个table,以观其表内数据.以下罗列了三种种关于树形打印lua table的方法;法一 local print = print local tconcat = table.concat local tinsert = table.insert local srep = string.rep local type = type local pairs = pairs local tostring = tostring local next = nex…