Next: , Previous: , Up: lists   [Index]


23.5 Comparison

Function: list=? item= ell0 ...

Determines list equality, given an element–equality procedure item=. Proper list ell1 equals proper list ell2 if:

  1. They are of the same length.
  2. Their corresponding elements are equal, according to item=.

If there are no list arguments, or only one list argument: The return value is #t. If there are two or more list arguments they are compared in couples: First ell0 is compared to ell1, then ell1 is compared to ell2, etc. The iteration over list arguments stops if two list arguments are found different.

item= is applied to elements from two list arguments taken with the same order; the first from ell1, the second from ell2, etc. item= must be consistent with eq?:

(eq? x y) ⇒ (elm=? x y)

this implies that two lists which are eq? are always list=?, as well.

Examples:

(list=? eq?)
⇒ #t

(list=? eq? '(a))
⇒ #t

(list=? = '(1 2 3 4)
          '(1 2 3 4))
⇒ #t

(list=? = '(1 2 3 4)
          '(1 9 3 4))
⇒ #f

(list=? = '(1 2 3 4)
          '(1 2 3 4)
          '(1 2 3 4))
⇒ #t

(list=? = '(1 2 3 4)
          '(1 2 3 4 5)
          '(1 2 3 4))
⇒ #f

(list=? = '())
⇒ #t

(list=? = '() '())
⇒ #t

(list=? = '() '() '())
⇒ #t