Fundamentals of CS I (CS151 2001S) : Reference

equal? - determine if two values are equal

Parametersval1, a value
val2, another value
PurposeDetermines if val1 and val2 are equal, even if they are complex structures. Compares individual elements in lists.. Particularly appropriate for lists, strings, and vectors.
ProducesA truth value: true (#t) if the two values are equal in the given sense, false (#f) if they're not.
PreconditionsExactly two parameters (verified).
> (equal? 2 2)
> (equal? 2 2 2)
equal?: expects 2 arguments, given 3: 2 2 2
> (equal? 2 (+ 1 1))
> (equal? "hello" "hello")
> (equal? 'hello 'hello)
> (equal? 'hello (car (list 'hello 'goodbye)))
> (equal? null null)
> (equal? (cons 'a null) (cons 'a null))
> (equal? 5.0 5)
> (equal? 5.0 5.0)

Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This page was generated by Siteweaver on Thu Feb 22 05:47:55 2001.
This page may be found at
You may validate this page's HTML.
The source was last modified Fri Feb 2 06:39:31 2001.