XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

equal


Type:   -   predicate function (subr)
Source:   -   xllist.c, xlsubr.c

Syntax

(equal expr1 expr2)
expr1 - the first expression to compare
expr2 - the second expression to compare
returns -  T  if the expressions print to the same value, NIL otherwise

Description

The 'equal' predicate checks to see if 'expr1' and 'expr2' are structurally equivalent.  T  is returned if they are equivalent, NIL is returned otherwise.

Examples

(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 XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next