| 54 | |
| 55 | |
| 56 | static int maxn (lua_State *L) { |
| 57 | lua_Number max = 0; |
| 58 | luaL_checktype(L, 1, LUA_TTABLE); |
| 59 | lua_pushnil(L); /* first key */ |
| 60 | while (lua_next(L, 1)) { |
| 61 | lua_pop(L, 1); /* remove value */ |
| 62 | if (lua_type(L, -1) == LUA_TNUMBER) { |
| 63 | lua_Number v = lua_tonumber(L, -1); |
| 64 | if (v > max) max = v; |
| 65 | } |
| 66 | } |
| 67 | lua_pushnumber(L, max); |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | static int getn (lua_State *L) { |
nothing calls this directly
no test coverage detected