
- 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 - 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 list 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_list({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_list to convert a tuple to a list.
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 list. |
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 list 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 list of all ports on the local node |
11 |
Returns a list 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). |