Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created November 3, 2020 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/5a4a75c8d250059b606b5899c60ab927 to your computer and use it in GitHub Desktop.
Save cuongld2/5a4a75c8d250059b606b5899c60ab927 to your computer and use it in GitHub Desktop.
sum recursive functions
def sum(xs: List[Int]): Int = {
if( xs.isEmpty)
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