Erlang – from_list

Erlang from_list

In this guide, we will discuss Erlang from_list. 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}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply