当前位置: 首页 > 文档资料 > Erlang 中文教程 >

merge

优质
小牛编辑
117浏览
2023-12-01

返回合并ListOfLists的所有子列表形成的排序列表。 在评估此功能之前,必须对所有这些子列表进行排序。 当两个元素比较相等时,在ListOfLists中具有最低位置的子列表中的元素在另一个元素之前被选中。

语法 (Syntax)

merge(ListsofLists)

参数 (Parameters)

  • ListsofLists - 需要合并的列表集合。

返回值 (Return Value)

返回合并的元素列表。

例如 (For example)

-module(helloworld). 
-import(lists,[merge/1]). 
-export([start/0]). 
start() ->    
   io:fwrite("~w~n",[merge([[1],[2],[3]])]).

输出 (Output)

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

[1,2,3]