The 'equal' predicate checks to see if 'expr1' and 'expr2' are structurally equivalent. T is returned if they are equivalent, NIL is returned otherwise.
(equal 'a 'a) ; returns T (equal 1 1) ; returns T (equal 1 1.0) ; returns NIL (equal 1.0 1.0) ; returns T (equal "a" "a") ; returns T (equal '(a b) '(a b)) ; returns T (equal 'a 34) ; returns NIL (setq a '(a b)) ; set value of A to (A B) (setq b a) ; set B to point to A's value (setq c '(a b)) ; set value of C to dif. (A B) (equal a b) ; returns T (equal a c) ; returns T (equal '(a b) '(A B)) ; returns T (equal '(a b) '(c d)) ; returns NIL (equal "a" "A") ; returns NIL (equal "abc" "abcD") ; returns NIL
Note: A way to view 'equal' is that if 'expr1' and 'expr2' were printed [via print or princ], if they look the same, then 'equal' will return T .
See the
equal
predicate function in the