MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / luaB_range

Function luaB_range

src/lbaselib.cpp:791–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789
790
791static int luaB_range (lua_State *L) {
792 lua_Integer start, end, step;
793 if (!lua_isnoneornil(L, 2)) {
794 start = luaL_checkinteger(L, 1);
795 end = luaL_checkinteger(L, 2);
796 step = luaL_optinteger(L, 3, 1);
797 }
798 else {
799 start = 1;
800 end = luaL_checkinteger(L, 1);
801 step = 1;
802 }
803
804 lua_createtable(L, cast(int, end - start), 0);
805 lua_Integer idx = 1;
806 for (lua_Integer i = start; i <= end; i += step, ++idx) {
807 lua_pushinteger(L, i);
808 lua_rawseti(L, -2, idx);
809 L->checkEtl();
810 }
811 return 1;
812}
813
814
815static int luaB_sdiv (lua_State *L) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected