# Function TREE-EQUAL

### Syntax

• tree-equal tree-1 tree-2 `&key` test test-notgeneralized-boolean

### Description

tree-equal tests whether two trees are of the same shape and have the same leaves. tree-equal returns true if tree-1 and tree-2 are both atoms and satisfy the test, or if they are both conses and the car of tree-1 is tree-equal to the car of tree-2 and the cdr of tree-1 is tree-equal to the cdr of tree-2. Otherwise, tree-equal returns false.

tree-equal recursively compares conses but not any other objects that have components.

The first argument to the `:test` or `:test-not` function is tree-1 or a car or cdr of tree-1; the second argument is tree-2 or a car or cdr of tree-2.

### Examples

```
(defparameter *tree-1* '(1 (1 2))) → (1 (1 2))

→
*TREE-1*

(defparameter *tree-2* '(1 (1 2))) → (1 (1 2))

→
*TREE-2*

(tree-equal *tree-1* *tree-2*)

→
true

(eql *tree-1* *tree-2*)

→
false

(setf *tree-1* '('a ('b 'c)))

→
('a ('b 'c)) ; ≡ ((QUOTE A) ((QUOTE B) (QUOTE C)))

(setf *tree-2* '('a ('b 'c)))

→
('a ('b 'c)) ; ≡ ((QUOTE A) ((QUOTE B) (QUOTE C)))

(tree-equal *tree-1* *tree-2* :test #'eq)

→
true

```

None.

None.

### Exceptional Situations

The consequences are undefined if both tree-1 and tree-2 are circular.

Function EQUAL, {\secref\TraversalRules}

To be done.

### Notes

The `:test-not` parameter is deprecated.

\issue{DOTTED-LIST-ARGUMENTS:CLARIFY} \issue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE} \issue{TEST-NOT-IF-NOT:FLUSH-ALL}