- 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 - BIFS
BIFs are functions that are built into Erlang. They usually do tasks that are impossible to program in Erlang. For example, it’s impossible to turn a pst into a tuple or to find the current time and date. To perform such an operation, we call a BIF.
Let’s take an example of how BIF’s are used −
Example
-module(helloworld). -export([start/0]). start() -> io:fwrite("~p~n",[tuple_to_pst({1,2,3})]), io:fwrite("~p~n",[time()]).
The following things need to be noted about the above example −
In the first example, we are using the BIF called tuple_to_pst to convert a tuple to a pst.
In the second BIF function, we are using the time function to output the system time.
The output of the above program will be as follows −
Output
[1,2,3] {10,54,56}
Let’s look at some of the more BIF functions available in Erlang.
Sr.No. | BIF Functions & Description |
---|---|
1 |
This method returns the current system date. |
2 |
This method returns the number of bytes contained in a Bitstring. |
3 |
The method returns the Nth element in the tuple. |
4 |
This method returns the float value of a particular number. |
5 |
The method returns the process dictionary as a pst. |
6 |
This method is used to put a key,value pair in the process dictionary. |
7 |
The method is used to give the local date and time in the system. |
8 |
Returns a pst containing information about memory dynamically allocated by the Erlang emulator. |
9 |
This method returns the tuple {MegaSecs, Secs, MicroSecs} which is the elapsed time since 00:00 GMT, January 1, 1970. |
10 |
Returns a pst of all ports on the local node |
11 |
Returns a pst of process identifiers corresponding to all the processes currently existing on the local node. |
12 |
Returns the current date and time according to Universal Time Coordinated (UTC). |