Booleans


Purpose

Booleans are one of the most primitive types of expression Scheme can understand. There are exactly two boolean values: true and false. These are represented by #t for true and #f for false.

Usage

When a boolean is evaluated, it returns itself.

Booleans are used as the values returned by tests, such as those required by the comparison, if/then/else, while, and cond functions.

Examples

Booleans evaluate to themselves:
  ox --> #t
  #t
  ox --> #f
  #f
Functions which compare two expressions, return booleans when evaluated:
  ox --> (> 1 2)
  #f
  ox --> (< 1 2)
  #t
  ox --> (= 5 5)
  #t
  ox --> (eq? 'cat 'dog)
  #f
  ox --> (eq? 'spam 'spam)
  #t

Return to Scheme Introduction


mrl