Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何将列表转换为Erlang中的函数参数?_List_Function_Erlang - Fatal编程技术网

List 如何将列表转换为Erlang中的函数参数?

List 如何将列表转换为Erlang中的函数参数?,list,function,erlang,List,Function,Erlang,假设我有一个具有一定算术性的函数。我想给它提供相应的数字列表 显然,如果我有F/2函数和列表L=[1,2],我可以这样做: F(hd(L), hd(tl(L))). 但我怎样才能把它概括起来呢?我认为,应该有一些从列表到参数的简单转换,但我还不知道。看看函数。它做你想要的 > apply( fun (X,Y) -> X+Y end, [1,2]). 3 还有一个apply/3,其中也包括该函数的模块: > apply( io, format , [ "~p, ~p", [1

假设我有一个具有一定算术性的函数。我想给它提供相应的数字列表

显然,如果我有F/2函数和列表L=[1,2],我可以这样做:

F(hd(L), hd(tl(L))).
但我怎样才能把它概括起来呢?我认为,应该有一些从列表到参数的简单转换,但我还不知道。

看看函数。它做你想要的

> apply( fun (X,Y) -> X+Y end, [1,2]).
3
还有一个
apply/3
,其中也包括该函数的模块:

> apply( io, format , [ "~p, ~p", [1,2]]).        
1, 2