t3x.org / sketchy / library / equalp.html
SketchyLISP
Reference
  Copyright (C) 2006
Nils M Holm

equal?

Conformance: R5RS

Purpose: Compare two S-expressions. Return #t, if both expressions print equal.

Arguments:
A - expression
B - expression

Implementation:

(define (equal? a b)
  (cond ((number? a)
      (and (number? b) (= a b)))
    ((char? a)
      (and (char? b) (char=? a b)))
    ((string? a)
      (and (string? b) (string=? a b)))
    ((and (pair? a) (pair? b))
      (and (equal? (car a) (car b))
           (equal? (cdr a) (cdr b))))
; This is actually caught by eq?
;     ((or (procedure? a) (procedure? b))
;       (bottom))
    (#t (eq? a b))))

Example:

(equal? '(a b (c d (e)) f) '(a b (c d (e)) f)) 
=> #t

See also:
member, =.