Created
December 14, 2018 15:09
-
-
Save truthadjustr/f9aed479b689f36fe5c83099a03894ca to your computer and use it in GitHub Desktop.
fpython: sums list of numbers
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
# sums a list of numbers | |
def f (p): | |
if not isinstance (p,list): | |
raise ValueError ("type error") | |
x, *xs = p | |
return x if xs == [] else x + f (xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment