Skip to content

Instantly share code, notes, and snippets.

@Nublo
Created October 7, 2018 14:50
Show Gist options
  • Save Nublo/f9fbe703578115816f6db60d0b2f3efd to your computer and use it in GitHub Desktop.
Save Nublo/f9fbe703578115816f6db60d0b2f3efd to your computer and use it in GitHub Desktop.
tailrec fun sum(xs: List<Int>, acum: Int): Int = when (xs.size) {
0 -> acum
else -> sum(xs.tail, xs.head + acum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment