Next: , Previous: , Up: Data Types   [Contents][Index]

#### 5.3.4 Equality Predicates

Function: eq arg1 arg2

Returns true when arg1 and arg2 refer to the same object. Two objects are the same when they occupy the same place in memory and hence modifying one object would alter the other. The following Lisp fragments may illustrate this,

```(eq "foo" "foo")        ;the objects are distinct
⇒ ()

(eq t t)                ;the same object -- the symbol `t`
⇒ t
```

Note that the result of `eq` is undefined when called on two integer objects with the same value, see `eql`.

Function: equal arg1 arg2

The function `equal` compares the structure of the two objects arg1 and arg2. If they are considered to be equivalent then returns true, otherwise returns false.

```(equal "foo" "foo")
⇒ t

(equal 42 42)
⇒ t

(equal 42 0)
⇒ ()

(equal '(x . y) '(x . y))
⇒ t
```
Function: eql arg1 arg2

This function is a cross between `eq` and `equal`: if arg1 and arg2 are both numbers then the value of these numbers are compared. Otherwise it behaves in exactly the same manner as `eq` does. See also the document of `=`. (see Comparison Predicates.)

```(eql 3 3)
⇒ t

(eql 1 2)
⇒ ()

(eql "foo" "foo")
⇒ ()

(eql 'x 'x)
⇒ t
```