Erlang - merge


Advertisements


Returns the sorted list formed by merging all the sub-lists of ListOfLists. All these sub-lists must be sorted prior to evaluating this function. When two elements compare equal, the element from the sub-list with the lowest position in ListOfLists is picked before the other element.

Syntax

merge(ListsofLists)

Parameters

  • ListsofLists − Collection of Lists which need to be merged.

Return Value

Returns the merged list of elements.

For example

Live Demo
-module(helloworld). 
-import(lists,[merge/1]). 
-export([start/0]). 

start() ->    
   io:fwrite("~w~n",[merge([[1],[2],[3]])]).

Output

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

[1,2,3]

erlang_lists.htm

Advertisements