function table.slice(tbl, first, last, step)
local sliced = {}
for i = first or 1, last or #tbl, step or 1 do
sliced[#sliced+1] = tbl[i]
end
return sliced
end
local a = {1, 2, 3, 4}
local b = table.slice(a, 2, 3)
print(a[1], a[2], a[3], a[4])
print(b[1], b[2], b[3], b[4])
ICAgIGZ1bmN0aW9uIHRhYmxlLnNsaWNlKHRibCwgZmlyc3QsIGxhc3QsIHN0ZXApCiAgICAgIGxvY2FsIHNsaWNlZCA9IHt9CiAgICAgIAogICAgICBmb3IgaSA9IGZpcnN0IG9yIDEsIGxhc3Qgb3IgI3RibCwgc3RlcCBvciAxIGRvCiAgICAgICAgc2xpY2VkWyNzbGljZWQrMV0gPSB0YmxbaV0KICAgICAgZW5kCiAgICAgIAogICAgICByZXR1cm4gc2xpY2VkCiAgICBlbmQKICAgIAogICAgbG9jYWwgYSA9IHsxLCAyLCAzLCA0fQogICAgbG9jYWwgYiA9IHRhYmxlLnNsaWNlKGEsIDIsIDMpCiAgICBwcmludChhWzFdLCBhWzJdLCBhWzNdLCBhWzRdKQogICAgcHJpbnQoYlsxXSwgYlsyXSwgYlszXSwgYls0XSk=