On this page:
boolean?
not
equal?
eqv?
eq?
equal?/ recur
immutable?
prop: equal+ hash
3.1.1 Boolean Synonyms
true
false
symbol=?
boolean=?
false?
Version: 4.2.1

3.1 Booleans and Equality

True and false booleans are represented by the values #t and #f, respectively, though operations that depend a boolean value typically treat anything other than #f as true.

See also: and, or, andmap, ormap.

(boolean? v)  boolean?
  v : any/c
Returns #t if v is #t or #f, #f otherwise.

Examples:

  > (boolean? #f)

  #t

  > (boolean? #t)

  #t

  > (boolean? 'true)

  #f

(not v)  boolean?
  v : any/c
Returns #t if v is #f, #f otherwise.

Examples:

  > (not #f)

  #t

  > (not #t)

  #f

  > (not 'we-have-no-bananas)

  #f

(equal? v1 v2)  boolean?
  v1 : any/c
  v2 : any/c
Two values are equal? if and only if they are eqv?, unless otherwise specified for a particular datatype.

Datatypes with further specification of equal? include strings, byte strings, numbers, pairs, mutable pairs, vectors, hash tables, and inspectable structures. In the last five cases, equality is recursively defined; if both v1 and v2 contain reference cycles, they are equal when the infinite unfoldings of the values would be equal. See also prop:equal+hash.

Examples:

  > (equal? 'yes 'yes)

  #t

  > (equal? 'yes 'no)

  #f

  > (equal? (expt 2 100) (expt 2 100))

  #t

  > (equal? 2 2.0)

  #f

  > (equal? (make-string 3 #\z) (make-string 3 #\z))

  #t

(eqv? v1 v2)  boolean?
  v1 : any/c
  v2 : any/c
Two values are eqv? if and only if they are eq?, unless otherwise specified for a particular datatype.

The number and character datatypes are the only ones for which eqv? differs from eq?.

Examples:

  > (eqv? 'yes 'yes)

  #t

  > (eqv? 'yes 'no)

  #f

  > (eqv? (expt 2 100) (expt 2 100))

  #t

  > (eqv? 2 2.0)

  #f

  > (eqv? (integer->char 955) (integer->char 955))

  #t

  > (eqv? (make-string 3 #\z) (make-string 3 #\z))

  #f

(eq? v1 v2)  boolean?
  v1 : any/c
  v2 : any/c
Return #t if v1 and v2 refer to the same object, #f otherwise. See also Object Identity and Comparisons.

Examples:

  > (eq? 'yes 'yes)

  #t

  > (eq? 'yes 'no)

  #f

  > (let ([v (mcons 1 2)]) (eq? v v))

  #t

  > (eq? (mcons 1 2) (mcons 1 2))

  #f

  > (eq? (make-string 3 #\z) (make-string 3 #\z))

  #f

(equal?/recur v1 v2 recur-proc)  boolean?
  v1 : any/c
  v2 : any/c
  recur-proc : (any/c any/c -> any/c)
Like equal?, but using recur-proc for recursive comparisons (which means that reference cycles are not handled automatically). Non-#f results from recur-proc are converted to #t before being returned by equal?/recur.

Examples:

  > (equal?/recur 1 1 (lambda (a b) #f))

  #t

  > (equal?/recur '(1) '(1) (lambda (a b) #f))

  #f

  > (equal?/recur '#(1 1 1) '#(1 1.2 3/4)
                  (lambda (a b) (<= (abs (- a b)) 0.25)))

  #t

(immutable? v)  boolean?
  v : any/c
Returns #t if v is an immutable string, byte string, vector, hash table, or box, #f otherwise.

A structure type property (see Structure Type Properties) that supplies an equality predicate and hashing functions for a structure type. The property value must be a list of three procedures:

Take care to ensure that hash-proc and hash2-proc are consistent with equal-proc. Specifically, hash-proc and hash2-proc should produce the same value for any two structures for which equal-proc produces a true value.

When a structure type has no prop:equal+hash property, then transparent structures (i.e., structures with an inspector that is controlled by the current inspector) are equal? when they are instances of the same structure type (not counting sub-types), and when they have equal? field values. For transparent structures, equal-hash-code and equal-secondary-hash-code derive hash code using the field values. For opaque structure types, equal? is the same as eq?, and equal-hash-code and equal-secondary-hash-code results are based only on eq-hash-code.

3.1.1 Boolean Synonyms

The bindings documented in this section are provided by the scheme/bool and scheme libraries, but not scheme/base.

A synonym for #t.

A synonym for #f.

(symbol=? a b)  boolean?
  a : symbol?
  b : symbol?
Returns (equal? a b).

(boolean=? a b)  boolean?
  a : boolean?
  b : boolean?
Returns (equal? a b).

(false? v)  boolean?
  v : any/c
Returns (not v).