| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>tree-equal (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="tree-equal (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="tree-equal (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="Conses-Dictionary.html" rel="up" title="Conses Dictionary"> |
| 15 |
<link href="copy_002dlist.html" rel="next" title="copy-list"> |
| 16 |
<link href="subst.html" rel="prev" title="subst"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="tree_002dequal"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Next: <a href="copy_002dlist.html" accesskey="n" rel="next">copy-list</a>, Previous: <a href="subst.html" accesskey="p" rel="prev">subst</a>, Up: <a href="Conses-Dictionary.html" accesskey="u" rel="up">Conses Dictionary</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="tree_002dequal-_005bFunction_005d"></span><h4 class="subsection">14.2.13 tree-equal [Function]</h4> |
| 46 |
|
| 47 |
<p><code>tree-equal</code> <i>tree-1 tree-2 <span class="roman">&key</span> test test-not</i> ⇒ <i>generalized-boolean</i> |
| 48 |
</p> |
| 49 |
<span id="Arguments-and-Values_003a_003a-282"></span><h4 class="subsubheading">Arguments and Values::</h4> |
| 50 |
|
| 51 |
<p><i>tree-1</i>—a <i>tree</i>. |
| 52 |
</p> |
| 53 |
<p><i>tree-2</i>—a <i>tree</i>. |
| 54 |
</p> |
| 55 |
<p><i>test</i>—a <i>designator</i> for a <i>function</i> of two <i>arguments</i> |
| 56 |
that returns a <i>generalized boolean</i>. |
| 57 |
</p> |
| 58 |
<p><i>test-not</i>—a <i>designator</i> for |
| 59 |
a <i>function</i> of two <i>arguments</i> |
| 60 |
that returns a <i>generalized boolean</i>. |
| 61 |
</p> |
| 62 |
<p><i>generalized-boolean</i>—a <i>generalized boolean</i>. |
| 63 |
</p> |
| 64 |
<span id="Description_003a_003a-383"></span><h4 class="subsubheading">Description::</h4> |
| 65 |
|
| 66 |
<p><b>tree-equal</b> tests whether two trees are of the same shape |
| 67 |
and have the same leaves. |
| 68 |
<b>tree-equal</b> returns <i>true</i> if <i>tree-1</i> and <i>tree-2</i> are |
| 69 |
both <i>atoms</i> and <i>satisfy the test</i>, |
| 70 |
or if they are both <i>conses</i> and |
| 71 |
the <i>car</i> of <i>tree-1</i> is <b>tree-equal</b> to |
| 72 |
the <i>car</i> of <i>tree-2</i> and |
| 73 |
the <i>cdr</i> of <i>tree-1</i> is <b>tree-equal</b> to |
| 74 |
the <i>cdr</i> of <i>tree-2</i>. |
| 75 |
Otherwise, <b>tree-equal</b> returns <i>false</i>. |
| 76 |
</p> |
| 77 |
<p><b>tree-equal</b> recursively compares <i>conses</i> but not any |
| 78 |
other <i>objects</i> that have components. |
| 79 |
</p> |
| 80 |
<p>The first argument to the <tt>:test</tt> or <tt>:test-not</tt> |
| 81 |
function is <i>tree-1</i> or a <i>car</i> or <i>cdr</i> of <i>tree-1</i>; |
| 82 |
the second argument is <i>tree-2</i> or a <i>car</i> |
| 83 |
or <i>cdr</i> of <i>tree-2</i>. |
| 84 |
</p> |
| 85 |
<span id="Examples_003a_003a-266"></span><h4 class="subsubheading">Examples::</h4> |
| 86 |
|
| 87 |
<div class="example"> |
| 88 |
<pre class="example"> (setq tree1 '(1 (1 2)) |
| 89 |
tree2 '(1 (1 2))) ⇒ (1 (1 2)) |
| 90 |
(tree-equal tree1 tree2) ⇒ <i>true</i> |
| 91 |
(eql tree1 tree2) ⇒ <i>false</i> |
| 92 |
(setq tree1 '('a ('b 'c)) |
| 93 |
tree2 '('a ('b 'c))) ⇒ ('a ('b 'c)) |
| 94 |
⇒ ((QUOTE A) ((QUOTE B) (QUOTE C))) |
| 95 |
(tree-equal tree1 tree2 :test 'eq) ⇒ <i>true</i> |
| 96 |
</pre></div> |
| 97 |
|
| 98 |
<span id="Exceptional-Situations_003a_003a-119"></span><h4 class="subsubheading">Exceptional Situations::</h4> |
| 99 |
|
| 100 |
<p>The consequences are undefined |
| 101 |
if both <i>tree-1</i> and <i>tree-2</i> are circular. |
| 102 |
</p> |
| 103 |
<span id="See-Also_003a_003a-309"></span><h4 class="subsubheading">See Also::</h4> |
| 104 |
|
| 105 |
<p><a href="equal.html">equal</a> |
| 106 |
, |
| 107 |
</p> |
| 108 |
<p><a href="Traversal-Rules-and-Side-Effects.html">Traversal Rules and Side Effects</a> |
| 109 |
</p> |
| 110 |
<span id="Notes_003a_003a-203"></span><h4 class="subsubheading">Notes::</h4> |
| 111 |
|
| 112 |
<p>The <tt>:test-not</tt> parameter is deprecated. |
| 113 |
</p> |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
</body> |
| 118 |
</html> |