Erlang – merge

Erlang merge

In this guide, we will discuss Erlang merge. Returns the sorted list formed by merging all the sub-lists of List Of Lists. 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

-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]

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply