public static Varargs IPairs(LuaTable t) { var length = t.Length(); Func<double, object> func = index => { index++; return index > length ? null : new Varargs(index, t.GetValue(index)); }; return new Varargs(func, t, 0.0); }
public Varargs Unpack(LuaTable list, object i = null, object j = null) { var listLength = list.Length(); var startIndex = ConvertToNumber(i, 2, 1.0); var length = ConvertToNumber(j, 3, listLength); if (startIndex < 1) return Varargs.Empty; length = Math.Min(length, listLength - startIndex + 1); var array = new object[(int)length]; var arrayIndex = 0; for (var k = startIndex; k < startIndex + length; k++) array[arrayIndex++] = list.GetValue(k); return new Varargs(array); }