Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Maybe we need to zoom out of ancient languages...

Maybe. Compare your function to the equivalent Erlang one:

  sum(L) ->
    sum(L, 0).
  sum([], Acc) ->
    Acc;
  sum([Num|Rest], Acc) ->
    sum(Rest, Acc+Num).
Assuming that it's in a module called 'math', run it like so:

  math:sum([5,4,3,2,1]).
  15


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: