Or use the lists:foldl/2 function. This is copied directly from the Erlang Reference Manual.
1> lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]).
15
Or use the lists:foldl/2 function. This is copied directly from the Erlang Reference Manual.
1> lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]).
15