local I=script.Parent local t=I.Parent local c=require(t.t)local Z=c.tuple(c.table,c.callback)local function s(I,t,c)assert(Z(I,t))local s=c local J=1 if s==nil then s=I[1]J=2 end for c=J,#I,1 do s=t(s,I[c],c)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.callback)

local function reduce(list, reducer, initialReduction)
	assert(validate(list, reducer))

	local reduction = initialReduction
	local start = 1

	if reduction == nil then
		reduction = list[1]
		start = 2
	end

	for i = start, #list do
		reduction = reducer(reduction, list[i], i)
	end

	return reduction
end

return reduce