local I=script.Parent local t=I.Parent local c=require(t.t)local Z=c.tuple(c.table,c.optional(c.intersection(c.integer,c.numberMin(0))))local function s(I,t)assert(Z(I))local c={}local J=1 for I,Z in ipairs(I)do if type(Z)=="\116\097\098\108\101"and(not t or t>0)then local I=s(Z,t and t-1)for t=1,#I,1 do c[J]=I[t]J=J+1 end else c[J]=Z J=J+1 end end return c 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.intersection(t.integer, t.numberMin(0))))

local function flatten(list, depth)
	assert(validate(list))
	
	local new = {}
	local index = 1

	for _, v in ipairs(list) do
		if type(v) == "table" and (not depth or depth > 0) then
			local subList = flatten(v, depth and depth - 1)

			for j = 1, #subList do
				new[index] = subList[j]
				index = index + 1
			end
		else
			new[index] = v
			index = index + 1
		end
	end

	return new
end

return flatten