Created
October 7, 2018 14:51
-
-
Save Nublo/7c8a0d2dd2aa56d788477742d98b5101 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
fun sum(xs: List<Int>):Int { | |
tailrec fun sumInner(xs: List<Int>, acum: Int): Int = when (xs.size) { | |
0 -> acum | |
else -> sumInner(xs.tail, xs.head + acum) | |
} | |
return sumInner(xs, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment