Skip to content

Commit f2348ab

Browse files
committedNov 16, 2020
Redirect to new home for this content.
1 parent acb0ff6 commit f2348ab

File tree

1 file changed

+1
-228
lines changed
  • docs/current/user-guide/diving

1 file changed

+1
-228
lines changed
 

‎docs/current/user-guide/diving/2.html

+1-228
Original file line numberDiff line numberDiff line change
@@ -1,228 +1 @@
1-
<!doctype html>
2-
<html>
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="chrome=1">
7-
<title>Lisp Flavored Erlang</title>
8-
<link rel="stylesheet" href="/current/css/styles.css" />
9-
<link rel="stylesheet" href="/current/css/pygment_trac.css" />
10-
<link rel="shortcut icon" href="/current/images/favicon.ico" />
11-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
12-
<script src="/current/js/respond.js"></script>
13-
<!--[if lt IE 9]>
14-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
15-
<![endif]-->
16-
<!--[if lt IE 8]>
17-
<link rel="stylesheet" href="/current/css/ie.css">
18-
<![endif]-->
19-
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
20-
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
21-
</head>
22-
23-
24-
<body>
25-
<div id="header">
26-
<input type="checkbox" id="navbar-checkbox" class="navbar-checkbox">
27-
<label for="navbar-checkbox" class="navbar-handle">&#9776;</label>
28-
<nav>
29-
<ul>
30-
<li class="fork"><img src="https://raw.githubusercontent.com/lfe/docs/master/docs/current/images/logos/LispFlavoredErlang-xtiny.png" align="top" /></li>
31-
<li class="title"><a href="http://lfe.io/#resources">Download</a></li>
32-
<li class="title"><a href="/current/community.html">Community</a></li>
33-
<li class="title"><a href="/current/contributing.html">Contributing</a></li>
34-
<li class="title"><a href="http://lfe.gitbooks.io/quick-start/content/index.html">Quick Start</a></li>
35-
<li class="title"><a href="/current/">Home</a></li>
36-
</ul>
37-
</nav>
38-
</div><!-- end header -->
39-
40-
<div class="wrapper">
41-
42-
43-
<div id="sidebar-primary" class="sidebar">
44-
<div class="widget">
45-
<h3 class="widget-title">User Guide Sections</h3>
46-
<ol>
47-
<li>Introduction</li>
48-
<ul>
49-
<li><a class="spec" href="/current/user-guide/intro/1.html">Introduction</a></li>
50-
<li><a class="spec" href="/current/user-guide/intro/2.html">The LFE REPL</a></li>
51-
<li><a class="spec" href="/current/user-guide/intro/3.html">Loading Files</a></li>
52-
<li><a class="spec" href="/current/user-guide/intro/4.html">Setting up a Development Environment</a></li>
53-
</ul>
54-
55-
<li>Diving In</li>
56-
<ul>
57-
<li><a class="spec" href="/current/user-guide/diving/1.html">Numbers & Operators</a></li>
58-
<li><a class="spec" href="/current/user-guide/diving/2.html">Strings & Atoms</a></li>
59-
<li><a class="spec" href="/current/user-guide/diving/3.html">Binary & Bitstrings</a></li>
60-
<li><a class="spec" href="/current/user-guide/diving/4.html">Variables</a></li>
61-
<li><a class="spec" href="/current/user-guide/diving/5.html">Pattern Matching</a></li>
62-
</ul>
63-
64-
<li>Lists & Simple Data (in progress)</li>
65-
<ul>
66-
<li><a class="spec" href="/current/user-guide/data/1.html">Lists & Tuples</a></li>
67-
<li><a class="spec" href="/current/user-guide/data/2.html">Comprehensions</a></li>
68-
<li><a class="spec" href="/current/user-guide/data/3.html">Property Lists & Hashes</a></li>
69-
<li><a class="spec" href="/current/user-guide/data/4.html">Records</a></li>
70-
<li><a class="spec" href="/current/user-guide/data/5.html">.hrl Header Files</a></li>
71-
</ul>
72-
73-
<li>Functions & Modules (stubbed)</li>
74-
<ul>
75-
<li><a class="spec" href="/current/user-guide/funcode/1.html">Functions</a></li>
76-
<li><a class="spec" href="/current/user-guide/funcode/2.html">LFE-Specific Functions </a></li>
77-
<li><a class="spec" href="/current/user-guide/funcode/3.html">Modules</a></li>
78-
</ul>
79-
80-
<li>Recursion</li>
81-
<ul>
82-
<li><a class="spec" href="/current/user-guide/recursion/1.html">History</a></li>
83-
<li><a class="spec" href="/current/user-guide/recursion/2.html">Peano Axioms</a></li>
84-
<li><a class="spec" href="/current/user-guide/recursion/3.html">Primitive Recursive</a></li>
85-
<li><a class="spec" href="/current/user-guide/recursion/4.html">Total Recursive</a></li>
86-
<li><a class="spec" href="/current/user-guide/recursion/5.html">The λ-Calculus</a></li>
87-
<li><a class="spec" href="/current/user-guide/recursion/6.html">Practical Examples</a></li>
88-
<li><a class="spec" href="/current/user-guide/recursion/7.html">Tail-Calls</a></li>
89-
</ul>
90-
91-
<li>Checks, Errors, & Tests (stubbed)</li>
92-
<ul>
93-
<li><a class="spec" href="/current/user-guide/check/1.html">Guards</a></li>
94-
<li><a class="spec" href="/current/user-guide/check/2.html">Exception Handling</a></li>
95-
<li><a class="spec" href="/current/user-guide/check/3.html">EUnit with LFE</a></li>
96-
</ul>
97-
98-
<li>Processes & Servers (stubbed)</li>
99-
<ul>
100-
<li><a class="spec" href="/current/user-guide/procs/1.html">TBD</a></li>
101-
</ul>
102-
103-
<li>External Data (stubbed)</li>
104-
<ul>
105-
<li><a class="spec" href="/current/tutorials/mnesia/1.html">Mnesia Tutorial</a></li>
106-
<li><a class="spec" href="/current/user-guide/extdata/1.html">TBD</a></li>
107-
</ul>
108-
109-
<li>Development & Deployment (stubbed)</li>
110-
<ul>
111-
<li><a class="spec" href="/current/user-guide/devops/1.html">Projects with Rebar</a></li>
112-
<li><a class="spec" href="/current/user-guide/devops/2.html">Working with Kerl</a></li>
113-
<li><a class="spec" href="/current/user-guide/devops/3.html">Creating a Library</a></li>
114-
<li><a class="spec" href="/current/user-guide/devops/4.html">Apps & Services</a></li>
115-
<li><a class="spec" href="/current/user-guide/devops/5.html">Releasing</a></li>
116-
<li><a class="spec" href="/current/user-guide/devops/6.html">Running in Production</a></li>
117-
</ul>
118-
119-
<li>Java Interop</li>
120-
<ul>
121-
<li><a class="spec" href="/current/user-guide/java/jinterface/1.html">JInterface</a></li>
122-
<li><a class="spec" href="/current/user-guide/java/erjang/1.html">Erjang</a></li>
123-
</ul>
124-
125-
<li>Additional Topics (stubbed)</li>
126-
<ul>
127-
<li><a class="spec" href="/current/user-guide/extra/1.html">Scripting</a></li>
128-
<li><a class="spec" href="/current/user-guide/extra/2.html">Macros</a></li>
129-
<li><a class="spec" href="/current/user-guide/extra/3.html">Writing for Multi-Core</a></li>
130-
</ul>
131-
132-
</ol>
133-
</div>
134-
</div>
135-
136-
137-
<div id="content">
138-
<article>
139-
<h1>2 Diving In</h1>
140-
141-
<h2>2.2 Atoms and Strings</h2>
142-
143-
<h3>2.2.1 Atoms</h3>
144-
145-
<p>Atoms are a data type in Erlang that is used to represent non-numerical
146-
constants. In LFE, the typographical limitations of Erlang don&#39;t apply, since
147-
they&#39;re always quoted in LFE ;-)</p>
148-
149-
<p>Atoms have a value: the same as their text:</p>
150-
151-
<figure class="highlight"><pre><code class="language-cl" data-lang="cl"><span class="nb">&gt;</span> <span class="ss">&#39;strag</span>
152-
<span class="nv">strag</span>
153-
<span class="nb">&gt;</span></code></pre></figure>
154-
155-
<p>We saw this in the section on Boolean operators with the atoms of <code>true</code>
156-
and <code>false</code>. Since there are no Boolean types in Erlang or LFE, the atoms
157-
<code>true</code> and <code>false</code> are used instead.</p>
158-
159-
<p>Here are some more examples of atoms:</p>
160-
161-
<figure class="highlight"><pre><code class="language-cl" data-lang="cl"><span class="nb">&gt;</span> <span class="ss">&#39;Vogon</span>
162-
<span class="nv">Vogon</span>
163-
<span class="nb">&gt;</span> <span class="ss">&#39;_Gargle_Blaster</span>
164-
<span class="nv">_Gargle_Blaster</span>
165-
<span class="nb">&gt;</span> <span class="ss">&#39;+</span>
166-
<span class="nb">+</span>
167-
<span class="nb">&gt;</span> <span class="ss">&#39;*</span>
168-
<span class="nb">*</span>
169-
<span class="nb">&gt;</span> <span class="ss">&#39;|and now with hyperspace bypasses|</span>
170-
<span class="nv">|and now with hyperspace bypasses|</span>
171-
<span class="nb">&gt;</span></code></pre></figure>
172-
173-
<p>Though very simple, atoms have a huge impact on our everyday use of Erlang and
174-
LFE, primarily in the area of pattern matching. Hold that thought, though;
175-
we&#39;re not quite ready for it yet!</p>
176-
177-
<p>Furthermore, atoms are stored differently in Erlang than strings. They take up
178-
less space and are more efficient to compare than strings.</p>
179-
180-
<h3>2.2.2 Strings</h3>
181-
182-
<p>Now we come to the oddball of Erlang: the string. In truth, there is no such
183-
thing. Strings in Erlang are just lists of integers:</p>
184-
185-
<figure class="highlight"><pre><code class="language-cl" data-lang="cl"><span class="nb">&gt;</span> <span class="s">&quot;Don&#39;t Panic.&quot;</span>
186-
<span class="s">&quot;Don&#39;t Panic.&quot;</span>
187-
<span class="nb">&gt;</span> <span class="p">(</span><span class="nb">list</span> <span class="mi">68</span> <span class="mi">111</span> <span class="mi">110</span> <span class="mi">39</span> <span class="mi">116</span> <span class="mi">32</span> <span class="mi">80</span> <span class="mi">97</span> <span class="mi">110</span> <span class="mi">105</span> <span class="mi">99</span> <span class="mi">46</span><span class="p">)</span>
188-
<span class="s">&quot;Don&#39;t Panic.&quot;</span>
189-
<span class="nb">&gt;</span></code></pre></figure>
190-
191-
<p>Because Erlang (and thus LFE) strings consume 8 bytes per character on 32-bit
192-
systems and 16 bytes on 64-bit systems, they are not very efficient. As such,
193-
if you need to work with long strings in LFE, you probably want to use
194-
<code>(binary ...)</code>, but that&#39;s in the next section :-)</p>
195-
196-
</article>
197-
198-
199-
<div class="pagination loop-pagination">
200-
201-
<a href="1.html" class="previous page-numbers spec">&larr; Previous</a> |
202-
203-
<a class="page-numbers spec" href="">Top</a> |
204-
<a class="page-numbers spec" href="/current/">Home</a>
205-
206-
| <a href="3.html" class="next page-numbers spec">Next &rarr;</a>
207-
208-
</div>
209-
210-
211-
212-
</div><!-- #content -->
213-
214-
</div>
215-
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
216-
<script type="text/javascript">
217-
var _gaq = _gaq || [];
218-
_gaq.push(['_setAccount', 'UA-38274766-1']);
219-
_gaq.push(['_trackPageview']);
220-
(function() {
221-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
222-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
223-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
224-
})();
225-
</script>
226-
</body>
227-
</html>
228-
1+
<meta http-equiv="refresh" content="0; url=https://cnbbooks.github.io/lfe-manual/current/part2/data-types/atoms.html" />

0 commit comments

Comments
 (0)
Please sign in to comment.