lists:sum/1
计算列表里每个元素的总和
用法:
sum(List) -> number()
内部实现:
%% sum(L) returns the sum of the elements in L -spec sum(List) -> number() when List :: [number()]. sum(L) -> sum(L, 0). sum([H|T], Sum) -> sum(T, Sum + H); sum([], Sum) -> Sum.
计算列表里每个元素的总和
lists:sum([1, 2, 3, 4, 5]).