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