目录

sum

返回列表中元素的总和。

语法 (Syntax)

sum(lst)

参数 (Parameters)

  • Lst - 元素列表。

返回值 (Return Value)

返回列表中元素的总和。

例如 (For example)

-module(helloworld). 
-import(lists,[sum/1]). 
-export([start/0]). 
start() -> 
   Lst1 = [5,6,4], 
   io:fwrite("~p~n",[sum(Lst1)]).

输出 (Output)

当我们运行上述程序时,我们将得到以下结果。

15
↑回到顶部↑
WIKI教程 @2018