eq
 
 
 

Determines whether two expressions are identical

(eq expr1 expr2) 

The eq function determines whether expr1 and expr2 are bound to the same object (by setq, for example).

Arguments

expr1

The expression to be compared.

expr2

The expression to compare with expr1.

Return Values

T if the two expressions are identical; otherwise nil.

Examples

Given the following assignments:

(setq f1 '(a b c)) 
(setq f2 '(a b c)) 
(setq f3 f2)

Compare f1 and f3:

Command: (eq f1 f3)

nil

eq returns nil because f1 and f3, while containing the same value, do not refer to the same list.

Compare f3 and f2:

Command: (eq f3 f2)

T

eq returns T because f3 and f2 refer to the same list.

See Also