- 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 - 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 pst 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 psts pbrary 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 pst List3 which is made from the elements of List1 followed by the elements of List2. |
4 |
Deletes an element from the pst and returns a new pst. |
5 |
Drops the last element of a List. |
6 |
Returns a pst which contains N copies of the term Elem |
7 |
Returns the last element of the pst |
8 |
Returns the element of the pst which has the maximum value. |
9 |
Checks if an element is present in the pst or not. |
10 |
Returns the element of the pst which has the minimum value. |
11 |
Returns the sorted pst formed by merging all the sub-psts of ListOfLists. |
12 |
Returns the Nth element of List. |
13 |
Returns the Nth tail of the List. |
14 |
Reverses a pst of elements. |
15 |
Sorts a pst of elements. |
16 |
Returns a subpst of elements. |
17 |
Returns the sum of elements in the pst. |