Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 110

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../otp_doc.css" type="text/css">
<title>Erlang -- Data Types</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="../pdf/otp-system-documentation-5.9.3.1.pdf">PDF</a><br><a href="../index.html">Top</a></small><p><strong>Erlang Reference Manual</strong><br><strong>User's Guide</strong><br><small>Version 5.9.3.1</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p>
<ul class="flipMenu" imagepath="../js/flipmenu">
<li id="no" title="Introduction" expanded="false">Introduction<ul>
<li><a href="introduction.html">
              Top of chapter
            </a></li>
<li title="Purpose"><a href="introduction.html#id73748">Purpose</a></li>
<li title="Prerequisites"><a href="introduction.html#id66106">Prerequisites</a></li>
<li title="Document Conventions"><a href="introduction.html#id67296">Document Conventions</a></li>
<li title="Complete List of BIFs"><a href="introduction.html#id68121">Complete List of BIFs</a></li>
<li title="Reserved Words"><a href="introduction.html#id60679">Reserved Words</a></li>
<li title="Character Set"><a href="introduction.html#id61758">Character Set</a></li>
</ul>
</li>
<li id="loadscrollpos" title="Data Types" expanded="true">Data Types<ul>
<li><a href="data_types.html">
              Top of chapter
            </a></li>
<li title="Terms"><a href="data_types.html#id63330">Terms</a></li>
<li title="Number"><a href="data_types.html#id68697">Number</a></li>
<li title="Atom"><a href="data_types.html#id62285">Atom</a></li>
<li title="Bit Strings and Binaries"><a href="data_types.html#id68011">Bit Strings and Binaries</a></li>
<li title="Reference"><a href="data_types.html#id58120">Reference</a></li>
<li title="Fun"><a href="data_types.html#id67499">Fun</a></li>
<li title="Port Identifier"><a href="data_types.html#id69290">Port Identifier</a></li>
<li title="Pid"><a href="data_types.html#id60853">Pid</a></li>
<li title="Tuple"><a href="data_types.html#id73719">Tuple</a></li>
<li title="List"><a href="data_types.html#id73198">List</a></li>
<li title="String"><a href="data_types.html#id68626">String</a></li>
<li title="Record"><a href="data_types.html#id65682">Record</a></li>
<li title="Boolean"><a href="data_types.html#id67471">Boolean</a></li>
<li title="Escape Sequences"><a href="data_types.html#id73885">Escape Sequences</a></li>
<li title="Type Conversions"><a href="data_types.html#id69219">Type Conversions</a></li>
</ul>
</li>
<li id="no" title="Pattern Matching" expanded="false">Pattern Matching<ul>
<li><a href="patterns.html">
              Top of chapter
            </a></li>
<li title="Pattern Matching"><a href="patterns.html#id68202">Pattern Matching</a></li>
</ul>
</li>
<li id="no" title="Modules" expanded="false">Modules<ul>
<li><a href="modules.html">
              Top of chapter
            </a></li>
<li title="Module Syntax"><a href="modules.html#id68326">Module Syntax</a></li>
<li title="Module Attributes"><a href="modules.html#id68358">Module Attributes</a></li>
<li title="Comments"><a href="modules.html#id74337">Comments</a></li>
<li title="The module_info/0 and module_info/1 functions"><a href="modules.html#id74350">The module_info/0 and module_info/1 functions</a></li>
</ul>
</li>
<li id="no" title="Functions" expanded="false">Functions<ul>
<li><a href="functions.html">
              Top of chapter
            </a></li>
<li title="Function Declaration Syntax"><a href="functions.html#id74609">Function Declaration Syntax</a></li>
<li title="Function Evaluation"><a href="functions.html#id74724">Function Evaluation</a></li>
<li title="Tail recursion"><a href="functions.html#id74875">Tail recursion</a></li>
<li title="Built-In Functions, BIFs"><a href="functions.html#id74908">Built-In Functions, BIFs</a></li>
</ul>
</li>
<li id="no" title="Types and Function Specifications" expanded="false">Types and Function Specifications<ul>
<li><a href="typespec.html">
              Top of chapter
            </a></li>
<li title="Introduction of Types"><a href="typespec.html#id75024">Introduction of Types</a></li>
<li title="Types and their Syntax"><a href="typespec.html#id75072">Types and their Syntax</a></li>
<li title="Type declarations of user-defined types"><a href="typespec.html#id75688">Type declarations of user-defined types</a></li>
<li title="Type information in record declarations"><a href="typespec.html#id75770">Type information in record declarations</a></li>
<li title="Specifications for functions"><a href="typespec.html#id75847">Specifications for functions</a></li>
</ul>
</li>
<li id="no" title="Expressions" expanded="false">Expressions<ul>
<li><a href="expressions.html">
              Top of chapter
            </a></li>
<li title="Expression Evaluation"><a href="expressions.html#id76067">Expression Evaluation</a></li>
<li title="Terms"><a href="expressions.html#id76110">Terms</a></li>
<li title="Variables"><a href="expressions.html#id76122">Variables</a></li>
<li title="Patterns"><a href="expressions.html#id76253">Patterns</a></li>
<li title="Match"><a href="expressions.html#id76372">Match</a></li>
<li title="Function Calls"><a href="expressions.html#id76431">Function Calls</a></li>
<li title="If"><a href="expressions.html#id76631">If</a></li>
<li title="Case"><a href="expressions.html#id76696">Case</a></li>
<li title="Send"><a href="expressions.html#id76761">Send</a></li>
<li title="Receive"><a href="expressions.html#id76844">Receive</a></li>
<li title="Term Comparisons"><a href="expressions.html#id77009">Term Comparisons</a></li>
<li title="Arithmetic Expressions"><a href="expressions.html#id77270">Arithmetic Expressions</a></li>
<li title="Boolean Expressions"><a href="expressions.html#id77776">Boolean Expressions</a></li>
<li title="Short-Circuit Expressions"><a href="expressions.html#id77931">Short-Circuit Expressions</a></li>
<li title="List Operations"><a href="expressions.html#id78047">List Operations</a></li>
<li title="Bit Syntax Expressions"><a href="expressions.html#id78116">Bit Syntax Expressions</a></li>
<li title="Fun Expressions"><a href="expressions.html#id78658">Fun Expressions</a></li>
<li title="Catch and Throw"><a href="expressions.html#id78840">Catch and Throw</a></li>
<li title="Try"><a href="expressions.html#id78986">Try</a></li>
<li title="Parenthesized Expressions"><a href="expressions.html#id79344">Parenthesized Expressions</a></li>
<li title="Block Expressions"><a href="expressions.html#id79376">Block Expressions</a></li>
<li title="List Comprehensions"><a href="expressions.html#id79401">List Comprehensions</a></li>
<li title="Bit String Comprehensions"><a href="expressions.html#id79541">Bit String Comprehensions</a></li>
<li title="Guard Sequences"><a href="expressions.html#id79673">Guard Sequences</a></li>
<li title="Operator Precedence"><a href="expressions.html#id80211">Operator Precedence</a></li>
</ul>
</li>
<li id="no" title="The Preprocessor" expanded="false">The Preprocessor<ul>
<li><a href="macros.html">
              Top of chapter
            </a></li>
<li title="File Inclusion"><a href="macros.html#id80530">File Inclusion</a></li>
<li title="Defining and Using Macros"><a href="macros.html#id80659">Defining and Using Macros</a></li>
<li title="Predefined Macros"><a href="macros.html#id80782">Predefined Macros</a></li>
<li title="Macros Overloading"><a href="macros.html#id80850">Macros Overloading</a></li>
<li title="Flow Control in Macros"><a href="macros.html#id80919">Flow Control in Macros</a></li>
<li title="Stringifying Macro Arguments"><a href="macros.html#id81056">Stringifying Macro Arguments</a></li>
</ul>
</li>
<li id="no" title="Records" expanded="false">Records<ul>
<li><a href="records.html">
              Top of chapter
            </a></li>
<li title="Defining Records"><a href="records.html#id81178">Defining Records</a></li>
<li title="Creating Records"><a href="records.html#id81209">Creating Records</a></li>
<li title="Accessing Record Fields"><a href="records.html#id81264">Accessing Record Fields</a></li>
<li title="Updating Records"><a href="records.html#id81303">Updating Records</a></li>
<li title="Records in Guards"><a href="records.html#id81336">Records in Guards</a></li>
<li title="Records in Patterns"><a href="records.html#id81368">Records in Patterns</a></li>
<li title="Nested records"><a href="records.html#id81395">Nested records</a></li>
<li title="Internal Representation of Records"><a href="records.html#id81430">Internal Representation of Records</a></li>
</ul>
</li>
<li id="no" title="Errors and Error Handling" expanded="false">Errors and Error Handling<ul>
<li><a href="errors.html">
              Top of chapter
            </a></li>
<li title="Terminology"><a href="errors.html#id81550">Terminology</a></li>
<li title="Exceptions"><a href="errors.html#id81678">Exceptions</a></li>
<li title="Handling of Run-Time Errors in Erlang"><a href="errors.html#id81851">Handling of Run-Time Errors in Erlang</a></li>
<li title="Exit Reasons"><a href="errors.html#id81913">Exit Reasons</a></li>
</ul>
</li>
<li id="no" title="Processes" expanded="false">Processes<ul>
<li><a href="processes.html">
              Top of chapter
            </a></li>
<li title="Processes"><a href="processes.html#id82387">Processes</a></li>
<li title="Process Creation"><a href="processes.html#id82400">Process Creation</a></li>
<li title="Registered Processes"><a href="processes.html#id82449">Registered Processes</a></li>
<li title="Process Termination"><a href="processes.html#id82560">Process Termination</a></li>
<li title="Message Sending"><a href="processes.html#id82650">Message Sending</a></li>
<li title="Links"><a href="processes.html#id82679">Links</a></li>
<li title="Error Handling"><a href="processes.html#id82744">Error Handling</a></li>
<li title="Monitors"><a href="processes.html#id82854">Monitors</a></li>
<li title="Process Dictionary"><a href="processes.html#id82946">Process Dictionary</a></li>
</ul>
</li>
<li id="no" title="Distributed Erlang" expanded="false">Distributed Erlang<ul>
<li><a href="distributed.html">
              Top of chapter
            </a></li>
<li title="Distributed Erlang System"><a href="distributed.html#id83013">Distributed Erlang System</a></li>
<li title="Nodes"><a href="distributed.html#id83044">Nodes</a></li>
<li title="Node Connections"><a href="distributed.html#id83114">Node Connections</a></li>
<li title="epmd"><a href="distributed.html#id83164">epmd</a></li>
<li title="Hidden Nodes"><a href="distributed.html#id83184">Hidden Nodes</a></li>
<li title="C Nodes"><a href="distributed.html#id83230">C Nodes</a></li>
<li title="Security"><a href="distributed.html#id83254">Security</a></li>
<li title="Distribution BIFs"><a href="distributed.html#id83364">Distribution BIFs</a></li>
<li title="Distribution Command Line Flags"><a href="distributed.html#id83662">Distribution Command Line Flags</a></li>
<li title="Distribution Modules"><a href="distributed.html#id83799">Distribution Modules</a></li>
</ul>
</li>
<li id="no" title="Compilation and Code Loading" expanded="false">Compilation and Code Loading<ul>
<li><a href="code_loading.html">
              Top of chapter
            </a></li>
<li title="Compilation"><a href="code_loading.html#id84002">Compilation</a></li>
<li title="Code Loading"><a href="code_loading.html#id84112">Code Loading</a></li>
<li title="Code Replacement"><a href="code_loading.html#id84159">Code Replacement</a></li>
<li title="Running a function when a module is loaded"><a href="code_loading.html#id84234">Running a function when a module is loaded</a></li>
</ul>
</li>
<li id="no" title="Ports and Port Drivers" expanded="false">Ports and Port Drivers<ul>
<li><a href="ports.html">
              Top of chapter
            </a></li>
<li title="Ports"><a href="ports.html#id84374">Ports</a></li>
<li title="Port Drivers"><a href="ports.html#id84409">Port Drivers</a></li>
<li title="Port BIFs"><a href="ports.html#id84449">Port BIFs</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>2 Data Types</h1>
  

  <h3><a name="id63330">2.1 
        Terms</a></h3>
    
    <p>Erlang provides a number of data types which are listed in this
      chapter. A piece of data of any data type is called a
      <strong>term</strong>.</p>
  

  <h3><a name="id68697">2.2 
        Number</a></h3>
    
    <p>There are two types of numeric literals, <strong>integers</strong> and
      <strong>floats</strong>. Besides the conventional notation, there are two
      Erlang-specific notations:</p>
    <ul>
      <li>
<span class="code">$</span><strong><span class="code">char</span></strong>      <br>

       ASCII value of the character <strong><span class="code">char</span></strong>.</li>
      <li>
<strong><span class="code">base</span></strong><span class="code">#</span><strong><span class="code">value</span></strong>      <br>

       Integer with the base <strong><span class="code">base</span></strong>, which must be an
       integer in the range 2..36.      <br>

       In Erlang 5.2/OTP R9B and earlier versions, the allowed range
       is 2..16.</li>
    </ul>
    <p>Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">42.</span>
42
2&gt; <span class="bold_code">$A.</span>
65
3&gt; <span class="bold_code">$\n.</span>
10
4&gt; <span class="bold_code">2#101.</span>
5
5&gt; <span class="bold_code">16#1f.</span>
31
6&gt; <span class="bold_code">2.3.</span>
2.3
7&gt; <span class="bold_code">2.3e3.</span>
2.3e3
8&gt; <span class="bold_code">2.3e-3.</span>
0.0023</pre></div>
  

  <h3><a name="id62285">2.3 
        Atom</a></h3>
    
    <p>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 @.</p>
    <p>Examples:</p>
    <div class="example"><pre>
hello
phone_number
'Monday'
'phone number'</pre></div>
  

  <h3><a name="id68011">2.4 
        Bit Strings and Binaries</a></h3>
    
    <p>A bit string is used to store an area of untyped memory.</p>
    <p>Bit Strings are expressed using the
      <span class="bold_code"><a href="expressions.html#bit_syntax">bit syntax</a></span>.</p>
    <p>Bit Strings which consists of a number of bits which is evenly 
      divisible by eight are called Binaries</p>
    <p>Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">&lt;&lt;10,20&gt;&gt;.</span>
&lt;&lt;10,20&gt;&gt;
2&gt; <span class="bold_code">&lt;&lt;"ABC"&gt;&gt;.</span>
&lt;&lt;"ABC"&gt;&gt;
1&gt; <span class="bold_code">&lt;&lt;1:1,0:1&gt;&gt;.</span>
&lt;&lt;2:2&gt;&gt;</pre></div>
    <p>More examples can be found in Programming Examples.</p>
  

  <h3><a name="id58120">2.5 
        Reference</a></h3>
    
    <p>A reference is a term which is unique in an Erlang runtime
      system, created by calling <span class="code">make_ref/0</span>.</p>
  

  <h3><a name="id67499">2.6 
        Fun</a></h3>
    
    <p>A fun is a functional object. Funs make it possible to create
      an anonymous function and pass the function itself -- not its
      name -- as argument to other functions.</p>
    <p>Example:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">Fun1 = fun (X) -&gt; X+1 end.</span>
#Fun&lt;erl_eval.6.39074546&gt;
2&gt; <span class="bold_code">Fun1(2).</span>
3</pre></div>
    <p>Read more about funs in <span class="bold_code"><a href="expressions.html#funs">Fun Expressions</a></span>. More examples can be found in Programming
      Examples.</p>
  

  <h3><a name="id69290">2.7 
        Port Identifier</a></h3>
    
    <p>A port identifier identifies an Erlang port. <span class="code">open_port/2</span>,
      which is used to create ports, will return a value of this type.</p>
    <p>Read more about ports in <span class="bold_code"><a href="ports.html">Ports and Port Drivers</a></span>.</p>
  

  <h3><a name="id60853">2.8 
        Pid</a></h3>
    
    <p>A process identifier, pid, identifies a process.
      <span class="code">spawn/1,2,3,4</span>, <span class="code">spawn_link/1,2,3,4</span> and
      <span class="code">spawn_opt/4</span>, which are used to create processes, return
      values of this type. Example:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">spawn(m, f, []).</span>
&lt;0.51.0&gt;</pre></div>
    <p>The BIF <span class="code">self()</span> returns the pid of the calling process.
      Example:</p>
    <div class="example"><pre>
-module(m).
-export([loop/0]).

loop() -&gt;
    receive
        who_are_you -&gt;
            io:format("I am ~p~n", [self()]),
            loop()
    end.

1&gt; <span class="bold_code">P = spawn(m, loop, []).</span>
&lt;0.58.0&gt;
2&gt; <span class="bold_code">P ! who_are_you.</span>
I am &lt;0.58.0&gt;
who_are_you</pre></div>
    <p>Read more about processes in
      <span class="bold_code"><a href="processes.html">Processes</a></span>.</p>
  

  <h3><a name="id73719">2.9 
        Tuple</a></h3>
    
    <p>Compound data type with a fixed number of terms:</p>
    <div class="example"><pre>
{Term1,...,TermN}</pre></div>
    <p>Each term <span class="code">Term</span> in the tuple is called an
      <strong>element</strong>. The number of elements is said to be
      the <strong>size</strong> of the tuple.</p>
    <p>There exists a number of BIFs to manipulate tuples.</p>
    <p>Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">P = {adam,24,{july,29}}.</span>
{adam,24,{july,29}}
2&gt; <span class="bold_code">element(1,P).</span>
adam
3&gt; <span class="bold_code">element(3,P).</span>
{july,29}
4&gt; <span class="bold_code">P2 = setelement(2,P,25).</span>
{adam,25,{july,29}}
5&gt; <span class="bold_code">tuple_size(P).</span>
3
6&gt; <span class="bold_code">tuple_size({}).</span>
0</pre></div>
  

  <h3><a name="id73198">2.10 
        List</a></h3>
    
    <p>Compound data type with a variable number of terms.</p>
    <div class="example"><pre>
[Term1,...,TermN]</pre></div>
    <p>Each term <span class="code">Term</span> in the list is called an
      <strong>element</strong>. The number of elements is said to be
      the <strong>length</strong> of the list.</p>
    <p>Formally, a list is either the empty list <span class="code">[]</span> or
      consists of a <strong>head</strong> (first element) and a <strong>tail</strong>
      (remainder of the list) which is also a list. The latter can
      be expressed as <span class="code">[H|T]</span>. The notation
      <span class="code">[Term1,...,TermN]</span> above is actually shorthand for
      the list <span class="code">[Term1|[...|[TermN|[]]]]</span>.</p>
    <p>Example:      <br>
<span class="code">[]</span> is a list, thus      <br>
<span class="code">[c|[]]</span> is a list, thus      <br>
<span class="code">[b|[c|[]]]</span> is a list, thus      <br>
<span class="code">[a|[b|[c|[]]]]</span> is a list, or in short <span class="code">[a,b,c]</span>.</p>
    <p></p>
    <p>A list where the tail is a list is sometimes called a <strong>proper list</strong>. It is allowed to have a list where the tail is not a
      list, for example <span class="code">[a|b]</span>. However, this type of list is of
      little practical use.</p>
    <p>Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">L1 = [a,2,{c,4}].</span>
[a,2,{c,4}]
2&gt; <span class="bold_code">[H|T] = L1.</span>
[a,2,{c,4}]
3&gt; <span class="bold_code">H.</span>
a
4&gt; <span class="bold_code">T.</span>
[2,{c,4}]
5&gt; <span class="bold_code">L2 = [d|T].</span>
[d,2,{c,4}]
6&gt; <span class="bold_code">length(L1).</span>
3
7&gt; <span class="bold_code">length([]).</span>
0</pre></div>
    <p>A collection of list processing functions can be found in
      the STDLIB module <span class="code">lists</span>.</p>
  

  <h3><a name="id68626">2.11 
        String</a></h3>
    
    <p>Strings are enclosed in double quotes ("), but is not a
      data type in Erlang. Instead a string <span class="code">"hello"</span> is
      shorthand for the list <span class="code">[$h,$e,$l,$l,$o]</span>, that is
      <span class="code">[104,101,108,108,111]</span>.</p>
    <p>Two adjacent string literals are concatenated into one. This is
      done at compile-time and does not incur any runtime overhead.
      Example:</p>
    <div class="example"><pre>
"string" "42"</pre></div>
    <p>is equivalent to</p>
    <div class="example"><pre>
"string42"</pre></div>
  

  <h3><a name="id65682">2.12 
        Record</a></h3>
    
    <p>A record is a data structure for storing a fixed number of
      elements. It has named fields and is similar to a struct in C.
      However, record is not a true data type. Instead record
      expressions are translated to tuple expressions during
      compilation. Therefore, record expressions are not understood by
      the shell unless special actions are taken. See <span class="code">shell(3)</span>
      for details.</p>
    <p>Examples:</p>
    <div class="example"><pre>
-module(person).
-export([new/2]).

-record(person, {name, age}).

new(Name, Age) -&gt;
    #person{name=Name, age=Age}.

1&gt; <span class="bold_code">person:new(ernie, 44).</span>
{person,ernie,44}</pre></div>
    <p>Read more about records in
      <span class="bold_code"><a href="records.html">Records</a></span>. More examples can be
      found in Programming Examples.</p>
  

  <h3><a name="id67471">2.13 
        Boolean</a></h3>
    
    <p>There is no Boolean data type in Erlang. Instead the atoms
      <span class="code">true</span> and <span class="code">false</span> are used to denote Boolean values.</p>
    <p>Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">2 =&lt; 3</span>.
true
2&gt; <span class="bold_code">true or false</span>.
true</pre></div>
  

  <h3><a name="id73885">2.14 
        Escape Sequences</a></h3>
    
    <p>Within strings and quoted atoms, the following escape sequences
      are recognized:</p>
    <table border="1" cellpadding="2" cellspacing="0">
<tr>
        <td align="left" valign="middle"><strong>Sequence</strong></td>
        <td align="left" valign="middle"><strong>Description</strong></td>
      </tr>
<tr>
        <td align="left" valign="middle">\b</td>
        <td align="left" valign="middle">backspace</td>
      </tr>
<tr>
        <td align="left" valign="middle">\d</td>
        <td align="left" valign="middle">delete</td>
      </tr>
<tr>
        <td align="left" valign="middle">\e</td>
        <td align="left" valign="middle">escape</td>
      </tr>
<tr>
        <td align="left" valign="middle">\f</td>
        <td align="left" valign="middle">form feed</td>
      </tr>
<tr>
        <td align="left" valign="middle">\n</td>
        <td align="left" valign="middle">newline</td>
      </tr>
<tr>
        <td align="left" valign="middle">\r</td>
        <td align="left" valign="middle">carriage return</td>
      </tr>
<tr>
        <td align="left" valign="middle">\s</td>
        <td align="left" valign="middle">space</td>
      </tr>
<tr>
        <td align="left" valign="middle">\t</td>
        <td align="left" valign="middle">tab</td>
      </tr>
<tr>
        <td align="left" valign="middle">\v</td>
        <td align="left" valign="middle">vertical tab</td>
      </tr>
<tr>
        <td align="left" valign="middle">\XYZ, \YZ, \Z</td>
        <td align="left" valign="middle">character with octal representation XYZ, YZ or Z</td>
      </tr>
<tr>
        <td align="left" valign="middle">\xXY</td>
        <td align="left" valign="middle">character with hexadecimal representation XY</td>
      </tr>
<tr>
        <td align="left" valign="middle">\x{X...}</td>
        <td align="left" valign="middle">character with hexadecimal representation; X... is one or more hexadecimal characters</td>
      </tr>
<tr>
        <td align="left" valign="middle">\^a...\^z        <br>
\^A...\^Z</td>
        <td align="left" valign="middle">control A to control Z</td>
      </tr>
<tr>
        <td align="left" valign="middle">\'</td>
        <td align="left" valign="middle">single quote</td>
      </tr>
<tr>
        <td align="left" valign="middle">\"</td>
        <td align="left" valign="middle">double quote</td>
      </tr>
<tr>
        <td align="left" valign="middle">\\</td>
        <td align="left" valign="middle">backslash</td>
      </tr>
</table>
<em>Table
        2.1:
         
        Recognized Escape Sequences.</em>
  

  <h3><a name="id69219">2.15 
        Type Conversions</a></h3>
    
    <p>There are a number of BIFs for type conversions. Examples:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code">atom_to_list(hello).</span>
"hello"
2&gt; <span class="bold_code">list_to_atom("hello").</span>
hello
3&gt; <span class="bold_code">binary_to_list(&lt;&lt;"hello"&gt;&gt;).</span>
"hello"
4&gt; <span class="bold_code">binary_to_list(&lt;&lt;104,101,108,108,111&gt;&gt;).</span>
"hello"
5&gt; <span class="bold_code">list_to_binary("hello").</span>
&lt;&lt;104,101,108,108,111&gt;&gt;
6&gt; <span class="bold_code">float_to_list(7.0).</span>
"7.00000000000000000000e+00"
7&gt; <span class="bold_code">list_to_float("7.000e+00").</span>
7.0
8&gt; <span class="bold_code">integer_to_list(77).</span>
"77"
9&gt; <span class="bold_code">list_to_integer("77").</span>
77
10&gt; <span class="bold_code">tuple_to_list({a,b,c}).</span>
[a,b,c]
11&gt; <span class="bold_code">list_to_tuple([a,b,c]).</span>
{a,b,c}
12&gt; <span class="bold_code">term_to_binary({a,b,c}).</span>
&lt;&lt;131,104,3,100,0,1,97,100,0,1,98,100,0,1,99&gt;&gt;
13&gt; <span class="bold_code">binary_to_term(&lt;&lt;131,104,3,100,0,1,97,100,0,1,98,100,0,1,99&gt;&gt;).</span>
{a,b,c}</pre></div>
  
</div>
<div class="footer">
<hr>
<p>Copyright © 2003-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>