
- Erlang Tutorial
- Erlang - Home
- Erlang - Overview
- Erlang - Environment
- Erlang - Basic Syntax
- Erlang - Shell
- Erlang - Data Types
- Erlang - Variables
- Erlang - Operators
- Erlang - Loops
- Erlang - Decision Making
- Erlang - Functions
- Erlang - Modules
- Erlang - Recursion
- Erlang - Numbers
- Erlang - Strings
- Erlang - Lists
- Erlang - File I/O
- Erlang - Atoms
- Erlang - Maps
- Erlang - Tuples
- Erlang - Records
- Erlang - Exceptions
- Erlang - Macros
- Erlang - Header Files
- Erlang - Preprocessors
- Erlang - Pattern Matching
- Erlang - Guards
- Erlang - BIFS
- Erlang - Binaries
- Erlang - Funs
- Erlang - Processes
- Erlang - Emails
- Erlang - Databases
- Erlang - Ports
- Erlang - Distributed Programming
- Erlang - OTP
- Erlang - Concurrency
- Erlang - Performance
- Erlang - Drivers
- Erlang - Web Programming
- Erlang Useful Resources
- Erlang - Quick Guide
- Erlang - Useful Resources
- Erlang - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Erlang - Lists
The List is a structure used to store a collection of data items. In Erlang, Lists are created by enclosing the values in square brackets.
Following is a simple example of creating a list of numbers in Erlang.
Example
-module(helloworld). -export([start/0]). start() -> Lst1 = [1,2,3], io:fwrite("~w~n",[Lst1]).
The output of the above example will be −
Output
[1 2 3]
Let us now discuss the various methods available for Lists. Note that the lists library needs to be imported for these methods to work.
Sr.No | Method and Description |
---|---|
1 |
Returns true if Pred(Elem) returns true for all elements Elem in List, otherwise false. |
2 |
Returns true if Pred(Elem) returns true for at least one element Elem in List. |
3 |
Returns a new list List3 which is made from the elements of List1 followed by the elements of List2. |
4 |
Deletes an element from the list and returns a new list. |
5 |
Drops the last element of a List. |
6 |
Returns a list which contains N copies of the term Elem |
7 |
Returns the last element of the list |
8 |
Returns the element of the list which has the maximum value. |
9 |
Checks if an element is present in the list or not. |
10 |
Returns the element of the list which has the minimum value. |
11 |
Returns the sorted list formed by merging all the sub-lists of ListOfLists. |
12 |
Returns the Nth element of List. |
13 |
Returns the Nth tail of the List. |
14 |
Reverses a list of elements. |
15 |
Sorts a list of elements. |
16 |
Returns a sublist of elements. |
17 |
Returns the sum of elements in the list. |