help with recursive function porting from js to unityscript?

I’m running into something I haven’t seen before. I’m trying to port over a piece of code from javascript to unityscript that does multiple regressions – finds the best fit for an equation with multiple factors like x1,x2,x3 etc… I’m not sure exactly what the function does, but it’s recursive and I don’t know how to fix the unity error I’m getting. I’d appreciate any help with this error:

The error in unity is
Assets/mregression.js(66,60): BCE0070: Definition of ‘det’ depends on ‘det’ whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.

function det(A)
	{
	var Length = A.length-1;
		// formal length of a matrix is one bigger
	if (Length == 1) return (A[1][1]);
	else
		{
		var sum = 0;
		var factor = 1;
		for (i = 1; i <= Length; i++)
			{
			if (A[1][i] != 0)
				{
				// create the minor
				minor = make0Array2(Length-1,Length-1);
				var theColumn;
				for (m = 1; m < Length; m++) // columns
					{
					if (m < i) theColumn = m;
					else theColumn = m+1;
					for (n = 1; n < Length; n++)
						{
						minor[n][m] = A[n+1][theColumn];
// Debug.Log(minor[n][m]);
						} // n
					} // m
				// compute its determinant
				sum = sum + A[1][i]*factor*det(minor);
				}
			factor = -factor;	// alternating sum
			} // end i
		} // recursion
	return(sum);
	} // end determinant

You need to define types for all variables. Assigning a value when the variable is declared is sufficient for defining a type, but “function det(A)” is not sufficient.

–Eric

If det returns an int then something like:

function det(A) : int

should work fine. Can’t really tell what det might be returning though.