Erlang Built-in Data Types
Integer |
Float |
Atom |
An atom is a literal, a constant with name. An atom should be enclosed in single quotes (') if it does not begin with a lower-case letter or if it contains other characters than alphanumeric characters, underscore (_), or @. |
bit string |
Store an area of untyped memory. e.g. <<"ABC">>. |
Binary |
A number of bit strings which is divisible by eight |
Reference |
An arbitrary "marker" than can be later use to reference a Process, function, etc. |
Fun |
A special variable that holds a function |
Port Identifier |
Used to identify a specific port when using port drivers |
Pid |
A process identifier. Usually returned by functions like spawn() |
Tuple {term, term} |
Compound data type with a fixed number of terms |
List |
Compound data type with a variable number of terms. |
String |
Not an actual data type. Stored as a list of integers |
Record |
A record is a data structure for storing a fixed number of elements. |
Boolean |
Not an actual data type, but the atoms true and false represent those values when testing |
|
|
BIF's: Type Conversion
atom_to_list(hello). |
"hello" |
list_to_atom("hello"). |
hello |
binary_to_list(<<"hello">>). |
"hello" |
list_to_binary("hello"). |
<<104,101,108,108,111>> |
float_to_list(7.0). |
"7.00000000000000000000e+00" |
list_to_float("7.000e+00"). |
7.0 |
tuple_to_list({a,b,c}). |
[a, b, c] |
list_to_tuple([a,b,c]). |
{a, b. c} |
term_to_binary({a,b,c}). |
<<131,104,3,100,0,1,97,100,0,1,98,100,0,1,99>> |
binary_to_term(<<131,104,3,100,0,1,97,100,0,1,98,100,0,1,99>>). |
{a, b, c} |
|
|
Module Attributes
-modules(name_of_module). |
-export([functions]). |
-import(module, functions). |
-compile(options). |
-vsn(Vsn). |
-on_load(function). |
-behavior(behavior). |
-record(Record,Fields). |
|