klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

booleans.texi (2853B)


      1 @c -*-texinfo-*-
      2 @setfilename ../src/booleans
      3 
      4 @node Booleans, Equivalence, Interpreter, Top
      5 @comment  node-name,  next,  previous,  up
      6 
      7 @chapter Booleans
      8 @cindex booleans
      9 
     10   The boolean data type consists of two values, which are called true
     11 and false, and have respectively external representations @code{#t}
     12 and @code{#f}.  There are no possible mutations of either of these two 
     13 @c add encapsulated cross ref
     14 values, and the boolean type is encapsulated.
     15 
     16 @deffn Applicative boolean? (boolean? . objects)
     17   The primitive type predicate for type boolean.  @code{boolean?}
     18 returns true iff all the objects in @code{objects} are of type boolean.
     19 @end deffn
     20 
     21 @deffn Applicative not? (not? boolean)
     22   Applicative @code{not?} is a predicate that returns the logical
     23 negation of its argument.
     24 @end deffn
     25 
     26 @deffn Applicative and? (and? . booleans)
     27   Applicative @code{and?} is a predicate that returns true unless one
     28 or more of its arguments are false.
     29 @end deffn
     30 
     31 @deffn Applicative or? (or? . booleans)
     32   Applicative @code{or?} is a predicate that returns false unless one
     33 or more of its arguments are true.
     34 @end deffn
     35 
     36 @deffn Operative $and? ($and? . <list>)
     37   The @code{$and?} operative performs a ``short-circuit and'' of its
     38 operands.  It evaluates them from left to right, until either an
     39 operand evaluates to false, or the end of the list is reached.  If the
     40 end of the list is reached (which is immediate if @code{<list>} is
     41 @code{nil}), the operative returns true.  If an operand evaluates to
     42 false, no further operand evaluations are performed, and the operative
     43 returns false.  If @code{<list>} is acyclic, and the last operand is
     44 @c TODO cross ref tail-context
     45 evaluated, it is evaluated in a special type of tail context that
     46 checks that the passed value is a boolean.  If @code{<list>} is
     47 cyclic, an unbounded number of operand evaluations may be performed.
     48 If any of the operands evaluates to a non-boolean value, an error is
     49 signaled (even if it's the last one).
     50 @end deffn
     51 
     52 @deffn Operative $or? ($or? . <list>)
     53   The @code{$or?} operative performs a ``short-circuit or'' of its
     54 operands.  It evaluates them from left to right, until either an
     55 operand evaluates to true, or the end of the list is reached.  If the
     56 end of the list is reached (which is immediate if @code{<list>} is
     57 @code{nil}), the operative returns false.  If an operand evaluates to
     58 true, no further operand evaluations are performed, and the operative
     59 returns true.  If @code{<list>} is acyclic, and the last operand is
     60 @c TODO cross ref tail-context
     61 evaluated, it is evaluated in a special type of tail context that
     62 checks that the passed value is a boolean.  If @code{<list>} is
     63 cyclic, an unbounded number of operand evaluations may be performed.
     64 If any of the operands evaluates to a non-boolean value, an error is
     65 signaled (even if it's the last one).
     66 @end deffn
     67