Created
October 24, 2013 22:12
-
-
Save tautologico/7146057 to your computer and use it in GitHub Desktop.
Function to sum all the values in a list of integers.
This file contains hidden or 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
fn sum_list(l: @IntList) -> int { | |
match *l { | |
Empty => 0, | |
Cons(i, rest) => i + sum_list(rest) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment