local I=script.Parent local t=I.Parent local c=require(t.t)local Z=c.tuple(c.table,c.optional(c.integer))local function s(I,t,...)assert(Z(I,t))local c=#I if t<1 then t=c+t end assert(t>0 and t<=c+1,string.format("\105\110\100\101\120 \037\100 \111\117\116 \111\102 \098\111\117\110\100\115 \111\102 \108\105\115\116 \111\102 \108\101\110\103\116\104 \037\100",t,c))local s={}local J=1 for c=1,c,1 do if c==t then for I=1,select("\035",...),1 do s[J]=select(I,...)J=J+1 end end s[J]=I[c]J=J+1 end return s end return s
local List = script.Parent

local Llama = List.Parent
local t = require(Llama.t)

local validate = t.tuple(t.table, t.optional(t.integer))

local function insert(list, index, ...)
	assert(validate(list, index))

	local len = #list

	if index < 1 then
		index = len + index
	end

	assert(index > 0 and index <= len + 1, string.format("index %d out of bounds of list of length %d", index, len))

	local new = {}
	local resultIndex = 1
	
	for i = 1, len do
		if i == index then
			for j = 1, select('#', ...) do
				new[resultIndex] = select(j, ...)
				resultIndex = resultIndex + 1
			end
		end
		
		new[resultIndex] = list[i]
		resultIndex = resultIndex + 1
	end

	return new
end

return insert