News for hackers. Stuff that matters.
Re:Study of non-programmers' solutions to programming proble... by simoncion on Friday April 15, 2016 @11:44PM (#11509192)
> 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

There are no comments on this comment yet.