summaryrefslogtreecommitdiff
path: root/devdocs/elisp/box-diagrams.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/box-diagrams.html
new repository
Diffstat (limited to 'devdocs/elisp/box-diagrams.html')
-rw-r--r--devdocs/elisp/box-diagrams.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/devdocs/elisp/box-diagrams.html b/devdocs/elisp/box-diagrams.html
new file mode 100644
index 00000000..f30af8eb
--- /dev/null
+++ b/devdocs/elisp/box-diagrams.html
@@ -0,0 +1,54 @@
+ <h4 class="subsubsection">Drawing Lists as Box Diagrams</h4> <p>A list can be illustrated by a diagram in which the cons cells are shown as pairs of boxes, like dominoes. (The Lisp reader cannot read such an illustration; unlike the textual notation, which can be understood by both humans and computers, the box illustrations can be understood only by humans.) This picture represents the three-element list <code>(rose violet buttercup)</code>: </p> <div class="example"> <pre class="example"> --- --- --- --- --- ---
+ | | |--&gt; | | |--&gt; | | |--&gt; nil
+ --- --- --- --- --- ---
+ | | |
+ | | |
+ --&gt; rose --&gt; violet --&gt; buttercup
+</pre>
+</div> <p>In this diagram, each box represents a slot that can hold or refer to any Lisp object. Each pair of boxes represents a cons cell. Each arrow represents a reference to a Lisp object, either an atom or another cons cell. </p> <p>In this example, the first box, which holds the <small>CAR</small> of the first cons cell, refers to or holds <code>rose</code> (a symbol). The second box, holding the <small>CDR</small> of the first cons cell, refers to the next pair of boxes, the second cons cell. The <small>CAR</small> of the second cons cell is <code>violet</code>, and its <small>CDR</small> is the third cons cell. The <small>CDR</small> of the third (and last) cons cell is <code>nil</code>. </p> <p>Here is another diagram of the same list, <code>(rose violet
+buttercup)</code>, sketched in a different manner: </p> <div class="example"> <pre class="example"> --------------- ---------------- -------------------
+| car | cdr | | car | cdr | | car | cdr |
+| rose | o--------&gt;| violet | o--------&gt;| buttercup | nil |
+| | | | | | | | |
+ --------------- ---------------- -------------------
+</pre>
+</div> <p>A list with no elements in it is the <em>empty list</em>; it is identical to the symbol <code>nil</code>. In other words, <code>nil</code> is both a symbol and a list. </p> <p>Here is the list <code>(A ())</code>, or equivalently <code>(A nil)</code>, depicted with boxes and arrows: </p> <div class="example"> <pre class="example"> --- --- --- ---
+ | | |--&gt; | | |--&gt; nil
+ --- --- --- ---
+ | |
+ | |
+ --&gt; A --&gt; nil
+</pre>
+</div> <p>Here is a more complex illustration, showing the three-element list, <code>((pine needles) oak maple)</code>, the first element of which is a two-element list: </p> <div class="example"> <pre class="example"> --- --- --- --- --- ---
+ | | |--&gt; | | |--&gt; | | |--&gt; nil
+ --- --- --- --- --- ---
+ | | |
+ | | |
+ | --&gt; oak --&gt; maple
+ |
+ | --- --- --- ---
+ --&gt; | | |--&gt; | | |--&gt; nil
+ --- --- --- ---
+ | |
+ | |
+ --&gt; pine --&gt; needles
+</pre>
+</div> <p>The same list represented in the second box notation looks like this: </p> <div class="example"> <pre class="example"> -------------- -------------- --------------
+| car | cdr | | car | cdr | | car | cdr |
+| o | o-------&gt;| oak | o-------&gt;| maple | nil |
+| | | | | | | | | |
+ -- | --------- -------------- --------------
+ |
+ |
+ | -------------- ----------------
+ | | car | cdr | | car | cdr |
+ ------&gt;| pine | o-------&gt;| needles | nil |
+ | | | | | |
+ -------------- ----------------
+</pre>
+</div><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Box-Diagrams.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Box-Diagrams.html</a>
+ </p>
+</div>