Created
March 11, 2018 06:16
-
-
Save talentdeficit/b7005845563ec6c272acd099e81530e3 to your computer and use it in GitHub Desktop.
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
sum(listOfInts) { sum(0, listOfInts); } | |
sum(acc, listOfInts) { | |
if length(listOfInts) == 0 { return acc; } | |
else { | |
acc += head(listOfInts); | |
sum(acc, tail(listOfInts); | |
} | |
} | |
sum(listOfInts) { | |
acc = 0; | |
for(i = 0, i < length(listOfInts), i++ { | |
acc += listOfInts[i]; | |
} | |
return acc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment