English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang List merge method

Erlang List

Returns a sorted list formed by merging all sublists of ListOfLists. Before evaluating this function, all these sublists must be sorted. When two elements are compared and are equal, the element from the ListOfLists sublist with the smallest position will be selected before the other element.

Syntax

merge(ListsofLists)

Parameter

  • ListsofLists −The collection of lists to be merged.

Return Value

Return the merged list of elements.

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

When we run the above program, we will get the following results.

[1,2,3]

Erlang List