Erlang - from_list


Advertisements

This method is used to generate a map from a list.

Syntax

from_list(Lst)

Parameters

  • Lst − This is the list which needs to be converted to a map.

Return Value

A map based on the list provided.

For example

-module(helloworld). 
-export([start/0]). 

start() ->   
   Lst1 = [{"a",1},{"b",2},{"c",3}], 
   io:fwrite("~p~n",[maps:from_list(Lst1)]).

Output

The output of the above program is as follows.

#{"a" => 1,"b" => 2,"c" => 3}
erlang_maps.htm
Advertisements