r7rs-small-texinfo

R7RS-small Scheme converted to Texinfo.
git clone https://kaka.farm/~git/r7rs-small-texinfo
Log | Files | Refs | README | LICENSE

booleans.texinfo (1984B)


      1 @node Booleans
      2 @section Booleans
      3 
      4 @cindex true
      5 @cindex false
      6 @sharpindex{t}
      7 @sharpindex{f}
      8 @sharpindex{true}
      9 @sharpindex{false}
     10 
     11 The standard boolean objects for true and false are written as @code{#t}
     12 and @code{#f}.  Alternatively, they can be written @code{#true} and
     13 @code{#false}, respectively.  What really matters, though, are the
     14 objects that the Scheme conditional expressions (@code{if}, @code{cond},
     15 @code{and}, @code{or}, @code{when}, @code{unless}, @code{do}) treat as
     16 true or false.  The phrase ``a true value'' (or sometimes just ``true'')
     17 means any object treated as true by the conditional expressions, and
     18 the phrase ``a false value'' (or ``false'') means any object treated as
     19 false by the conditional expressions.
     20 
     21 Of all the Scheme values, only @code{#f} counts as false in conditional
     22 expressions.  All other Scheme values, including @code{#t}, count as true.
     23 
     24 @cindex empty list
     25 
     26 Note: Unlike some other dialects of Lisp, Scheme distinguishes @code{#f}
     27 and the empty list empty list from each other and from the symbol
     28 @code{nil}.
     29 
     30 Boolean constants evaluate to themselves, so they do not need to be
     31 quoted in programs.
     32 
     33 @lisp
     34 #t  @result{} #t
     35 #f  @result{} #f
     36 '#f @result{} #f
     37 @end lisp
     38 
     39 @deffn procedure not obj
     40 
     41 The @code{not} procedure returns @code{#t} if @var{obj} is false, and
     42 returns @code{#f} otherwise.
     43 
     44 @lisp
     45 (not #t)       @result{} #f
     46 (not 3)        @result{} #f
     47 (not (list 3)) @result{} #f
     48 (not #f)       @result{} #t
     49 (not '())      @result{} #f
     50 (not (list))   @result{} #f
     51 (not 'nil)     @result{} #f
     52 @end lisp
     53 
     54 @end deffn
     55 
     56 @deffn procedure boolean? obj
     57 
     58 The @code{boolean?} predicate returns @code{#t} if @var{obj} is either
     59 @code{#t} or @code{#f} and returns @code{#f} otherwise.
     60 
     61 @lisp
     62 (boolean? #f)  @result{} #t
     63 (boolean? 0)   @result{} #f
     64 (boolean? '()) @result{} #f
     65 @end lisp
     66 
     67 @end deffn
     68 
     69 @deffn procedure boolean=? boolean1 boolean2 boolean3 @dots{}
     70 
     71 Returns @code{#t} if all the arguments are
     72 @code{#t} or all are @code{#f}.
     73 
     74 @end deffn