Last active
December 27, 2015 11:39
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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