klisp

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

Booleans.html (5207B)


      1 <html lang="en">
      2 <head>
      3 <title>Booleans - klisp Reference Manual</title>
      4 <meta http-equiv="Content-Type" content="text/html">
      5 <meta name="description" content="klisp Reference Manual">
      6 <meta name="generator" content="makeinfo 4.13">
      7 <link title="Top" rel="start" href="index.html#Top">
      8 <link rel="prev" href="Interpreter.html#Interpreter" title="Interpreter">
      9 <link rel="next" href="Equivalence.html#Equivalence" title="Equivalence">
     10 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
     11 <meta http-equiv="Content-Style-Type" content="text/css">
     12 <style type="text/css"><!--
     13   pre.display { font-family:inherit }
     14   pre.format  { font-family:inherit }
     15   pre.smalldisplay { font-family:inherit; font-size:smaller }
     16   pre.smallformat  { font-family:inherit; font-size:smaller }
     17   pre.smallexample { font-size:smaller }
     18   pre.smalllisp    { font-size:smaller }
     19   span.sc    { font-variant:small-caps }
     20   span.roman { font-family:serif; font-weight:normal; } 
     21   span.sansserif { font-family:sans-serif; font-weight:normal; } 
     22 --></style>
     23 <link rel="stylesheet" type="text/css" href="css/style.css">
     24 </head>
     25 <body>
     26 <div class="node">
     27 <a name="Booleans"></a>
     28 <p>
     29 Next:&nbsp;<a rel="next" accesskey="n" href="Equivalence.html#Equivalence">Equivalence</a>,
     30 Previous:&nbsp;<a rel="previous" accesskey="p" href="Interpreter.html#Interpreter">Interpreter</a>,
     31 Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
     32 <hr>
     33 </div>
     34 
     35 <!-- node-name,  next,  previous,  up -->
     36 <h2 class="chapter">3 Booleans</h2>
     37 
     38 <p><a name="index-booleans-13"></a>
     39   The boolean data type consists of two values, which are called true
     40 and false, and have respectively external representations <code>#t</code>
     41 and <code>#f</code>.  There are no possible mutations of either of these two
     42 <!-- add encapsulated cross ref -->
     43 values, and the boolean type is encapsulated.
     44 
     45 <div class="defun">
     46 &mdash; Applicative: <b>boolean?</b> (<var>boolean? . objects</var>)<var><a name="index-boolean_003f-14"></a></var><br>
     47 <blockquote><p>  The primitive type predicate for type boolean.  <code>boolean?</code>
     48 returns true iff all the objects in <code>objects</code> are of type boolean. 
     49 </p></blockquote></div>
     50 
     51 <div class="defun">
     52 &mdash; Applicative: <b>not?</b> (<var>not? boolean</var>)<var><a name="index-not_003f-15"></a></var><br>
     53 <blockquote><p>  Applicative <code>not?</code> is a predicate that returns the logical
     54 negation of its argument. 
     55 </p></blockquote></div>
     56 
     57 <div class="defun">
     58 &mdash; Applicative: <b>and?</b> (<var>and? . booleans</var>)<var><a name="index-and_003f-16"></a></var><br>
     59 <blockquote><p>  Applicative <code>and?</code> is a predicate that returns true unless one
     60 or more of its arguments are false. 
     61 </p></blockquote></div>
     62 
     63 <div class="defun">
     64 &mdash; Applicative: <b>or?</b> (<var>or? . booleans</var>)<var><a name="index-or_003f-17"></a></var><br>
     65 <blockquote><p>  Applicative <code>or?</code> is a predicate that returns false unless one
     66 or more of its arguments are true. 
     67 </p></blockquote></div>
     68 
     69 <div class="defun">
     70 &mdash; Operative: <b>$and?</b> (<var>$and? . &lt;list&gt;</var>)<var><a name="index-g_t_0024and_003f-18"></a></var><br>
     71 <blockquote><p>  The <code>$and?</code> operative performs a &ldquo;short-circuit and&rdquo; of its
     72 operands.  It evaluates them from left to right, until either an
     73 operand evaluates to false, or the end of the list is reached.  If the
     74 end of the list is reached (which is immediate if <code>&lt;list&gt;</code> is
     75 <code>nil</code>), the operative returns true.  If an operand evaluates to
     76 false, no further operand evaluations are performed, and the operative
     77 returns false.  If <code>&lt;list&gt;</code> is acyclic, and the last operand is
     78 <!-- TODO cross ref tail-context -->
     79 evaluated, it is evaluated in a special type of tail context that
     80 checks that the passed value is a boolean.  If <code>&lt;list&gt;</code> is
     81 cyclic, an unbounded number of operand evaluations may be performed. 
     82 If any of the operands evaluates to a non-boolean value, an error is
     83 signaled (even if it's the last one). 
     84 </p></blockquote></div>
     85 
     86 <div class="defun">
     87 &mdash; Operative: <b>$or?</b> (<var>$or? . &lt;list&gt;</var>)<var><a name="index-g_t_0024or_003f-19"></a></var><br>
     88 <blockquote><p>  The <code>$or?</code> operative performs a &ldquo;short-circuit or&rdquo; of its
     89 operands.  It evaluates them from left to right, until either an
     90 operand evaluates to true, or the end of the list is reached.  If the
     91 end of the list is reached (which is immediate if <code>&lt;list&gt;</code> is
     92 <code>nil</code>), the operative returns false.  If an operand evaluates to
     93 true, no further operand evaluations are performed, and the operative
     94 returns true.  If <code>&lt;list&gt;</code> is acyclic, and the last operand is
     95 <!-- TODO cross ref tail-context -->
     96 evaluated, it is evaluated in a special type of tail context that
     97 checks that the passed value is a boolean.  If <code>&lt;list&gt;</code> is
     98 cyclic, an unbounded number of operand evaluations may be performed. 
     99 If any of the operands evaluates to a non-boolean value, an error is
    100 signaled (even if it's the last one). 
    101 </p></blockquote></div>
    102 
    103 <!-- *-texinfo-*- -->
    104    </body></html>
    105