Type stability while looping over Tuple

Discovering this thread it can be resolve by recursion

function RecursiveUnroll(x::Tuple, i::Int)
	if length(x) == 0
		return nothing
	end
	# do what you want here
	RecursiveUnroll(x[2:end], i+1)
end

It still seems to me that this should be something the compiler could infer, as the range of the loop is static. Maybe someone could chip in here.

1 Like