DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(r5rs.info.gz) Booleans

Info Catalog (r5rs.info.gz) Other data types (r5rs.info.gz) Other data types (r5rs.info.gz) Pairs and lists
 
 6.3.1 Booleans
 --------------
 
 The standard boolean objects for true and false are written as #t and
 #f.  What really matters, though, are the objects that the Scheme
 conditional expressions (`if', `cond', `and', `or', `do') treat as true
 or false.  The phrase "a true value" (or sometimes just "true") means
 any object treated as true by the conditional expressions, and the
 phrase "a false value" (or "false") means any object treated as false
 by the conditional expressions.
 
 Of all the standard Scheme values, only #f counts as false in
 conditional expressions.  Except for #f, all standard Scheme values,
 including #t, pairs, the empty list, symbols, numbers, strings,
 vectors, and procedures, count as true.
 
      _Note:_ Programmers accustomed to other dialects of Lisp should be
      aware that Scheme distinguishes both #f and the empty list from
      the symbol `nil'.  
 
 Boolean constants evaluate to themselves, so they do not need to be
 quoted in programs.
 
 
      #t                                     ==>  #t
      #f                                     ==>  #f
      '#f                                    ==>  #f
 
  -- library procedure: not obj
      `Not' returns #t if OBJ is false, and returns #f otherwise.
 
      (not #t)                               ==>  #f
      (not 3)                                ==>  #f
      (not (list 3))                         ==>  #f
      (not #f)                               ==>  #t
      (not '())                              ==>  #f
      (not (list))                           ==>  #f
      (not 'nil)                             ==>  #f
 
 
  -- library procedure: boolean? obj
      `Boolean?' returns #t if OBJ is either #t or #f and returns #f
      otherwise.
 
      (boolean? #f)                          ==>  #t
      (boolean? 0)                           ==>  #f
      (boolean? '())                         ==>  #f
 
 
Info Catalog (r5rs.info.gz) Other data types (r5rs.info.gz) Other data types (r5rs.info.gz) Pairs and lists
automatically generated byinfo2html