manpagez: man pages & more
info r5rs
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 23, 2011 using texi2html 5.0.

© manpagez.com 2000-2019
Individual documents may contain additional copyright information.