Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active Dec 27, 2015
Embed
What would you like to do?
The Sum method after the tail call has been rewritten to a loop.
private static int Sum(List<int> numbers, int result = 0)
{
while (true)
{
int num = numbers.Count<int>();
if (num == 0)
{
break;
}
int index = num - 1;
int num2 = numbers[index];
numbers.RemoveAt(index);
List<int> arg_27_0 = numbers;
result = num2 + result;
numbers = arg_27_0;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment