XLISP equal

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# equal

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

## Syntax

(equal expr1 expr2)
  exprN - arbitrary Lisp expressions
  returns - T if the expressions are structurally equivalent, NIL otherwise

## Description

Two expressions are 'equal':

- If the expressions are eql.

- If two strings are string=.

- If the two cars in conses are 'equal' and the two cdrs in conses are 'equal'.

In all other cases 'equal' returns NIL. Note that arrays are only 'equal' if they are eq.

A way to view 'equal' is that if 'expr1' and 'expr2' were printed [via print or princ] and they look the same, then 'equal' will return T .

## Examples

    (equal 'a 'a)          => T
    (equal 1 1)            => T
    (equal 1 1.0)          => NIL  ; different number types
    (equal 1.0 1.0)        => T
    (equal "a" "a")        => T
    (equal '(a b) '(a b))  => T
    (equal 'a 34)          => 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 different (A B)
    (equal a b)            => T
    (equal a c)            => T

    (equal '(a b) '(A B))  => T
    (equal '(a b) '(c d))  => NIL

    (equal "a" "A")        => NIL
    (equal "abc" "abcD")   => NIL

See also eq, eql, cl:equalp.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference