Skip to content

Instantly share code, notes, and snippets.

@EarlOfEgo
Created July 14, 2016 19:27
Show Gist options
  • Save EarlOfEgo/d0279bd7d6feeaacd815d22895cce7ae to your computer and use it in GitHub Desktop.
Save EarlOfEgo/d0279bd7d6feeaacd815d22895cce7ae to your computer and use it in GitHub Desktop.
private int fold(List<Integer> input) {
if (input.size() == 0) {
return 0;
}
final int first = input.get(0);
if (input.size() == 1) {
return first;
}
return first + fold(input.subList(1, input.size()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment