Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active December 27, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/7320672 to your computer and use it in GitHub Desktop.
Save einarwh/7320672 to your computer and use it in GitHub Desktop.
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