Skip to content

Instantly share code, notes, and snippets.

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