- Erlang - Web Programming
- Erlang - Drivers
- Erlang - Performance
- Erlang - Concurrency
- Erlang - OTP
- Erlang - Distributed Programming
- Erlang - Ports
- Erlang - Databases
- Erlang - Emails
- Erlang - Processes
- Erlang - Funs
- Erlang - Binaries
- Erlang - BIFS
- Erlang - Guards
- Erlang - Pattern Matching
- Erlang - Preprocessors
- Erlang - Header Files
- Erlang - Macros
- Erlang - Exceptions
- Erlang - Records
- Erlang - Tuples
- Erlang - Maps
- Erlang - Atoms
- Erlang - File I/O
- Erlang - Lists
- Erlang - Strings
- Erlang - Numbers
- Erlang - Recursion
- Erlang - Modules
- Erlang - Functions
- Erlang - Decision Making
- Erlang - Loops
- Erlang - Operators
- Erlang - Variables
- Erlang - Data Types
- Erlang - Shell
- Erlang - Basic Syntax
- Erlang - Environment
- Erlang - Overview
- Erlang - Home
Erlang Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Erlang - Maps
A map is a compound data type with a variable number of key-value associations. Each key-value association in the map is called an association pair. The key and value parts of the pair are called elements. The number of association pairs is said to be the size of the map.
An example of how the Map data type can be used is shown in the following program.
Here we are defining a Map M1 which has 2 mappings. The map_size is an inbuilt function defined in Erlang which can be used to determine the size of the map.
Example
-module(helloworld). -export([start/0]). start() -> M1 = #{name=>john,age=>25}, io:fwrite("~w",[map_size(M1)]).
The output of the above program will be as follows.
Output
2
Some of the other methods available for maps are as follows.
Sr.No. | Methods & Description |
---|---|
1 |
This method is used to generate a map from a pst. |
2 |
This method is used to find if a particular key exists in the map. |
3 |
This method is used to get the value of a particular key in the map. |
4 |
This method is used to determine if a particular key is defined as a key in the map. |
5 |
This method is used to return all the keys from a map. |
6 |
This method is used to merge 2 maps. |
7 |
This method is used to add a key value pair to the map. |
8 |
This method is used to return all the values from a map. |
9 |
This method is used to remove a key value from the map. |