Google News
logo
Erlang - Interview Questions
Name the datatypes that erlang provides?
Erlang provides several built-in data types, including:

1. Atoms : Atoms are constants that represent unique symbolic values. They are often used as identifiers, flags, or tags. Examples of atoms in Erlang include `true`, `false`, and `ok`.

2. Numbers : Erlang supports different types of numbers, including integers and floating-point numbers. Integers can be of arbitrary precision, and floating-point numbers follow the IEEE 754 standard.

3. Tuples : Tuples are ordered collections of elements enclosed in curly braces `{}`. They can store elements of different data types and are often used to group related values together. For example, `{1, "hello", true}` is a tuple with three elements.

4. Lists : Lists are collections of elements enclosed in square brackets `[]`. They are often used to represent sequences of data. Erlang lists are linked lists and can contain elements of any data type. For example, `[1, 2, 3]` is a list of integers.
5. Binaries : Binaries are sequences of bits or bytes enclosed in `<<>>`. They are used to represent binary data and are commonly used for handling network protocols, file I/O, and encoding/decoding operations.

6. Strings : Erlang provides a specialized representation for strings using lists of integers. Each integer in the list represents the Unicode code point of a character. For example, `"hello"` is represented as the list `[104, 101, 108, 108, 111]`.

7. Maps : Maps are key-value data structures introduced in Erlang/OTP 17. They provide an efficient way to store and retrieve values based on keys. Maps can have keys of any data type and can store values of different types.

8. Functions : Erlang treats functions as first-class citizens. Functions can be assigned to variables, passed as arguments, and returned as results. They can be anonymous or named, providing flexibility in creating higher-order functions and implementing functional programming patterns.

These are the primary built-in data types in Erlang. Erlang's rich set of data types, combined with pattern matching and functional programming features, make it well-suited for handling complex data structures and developing expressive code.
Advertisement