Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/GAP/doc/ref/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 39 kB image not shown  

Quelle  chap22.html   Sprache: HTML

 
 products/sources/formale Sprachen/GAP/doc/ref/chap22.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 22: Boolean Lists</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap22"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap21.html">[Previous Chapter]</a>    <a href="chap23.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap22_mj.html">[MathJax on]</a></p>
<p><a id="X7AC531DD79B6938E" name="X7AC531DD79B6938E"></a></p>
<div class="ChapSects"><a href="chap22.html#X7AC531DD79B6938E">22 <span class="Heading">Boolean Lists</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap22.html#X7E7832B0804221AE">22.1 <span class="Heading">IsBlist (Filter)</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7BE078187A08DCEA">22.1-1 IsBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap22.html#X7CC745317FE54C14">22.2 <span class="Heading">Boolean Lists Representing Subsets</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7C597B2D87CA2E6E">22.2-1 BlistList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X874BEF63785AB439">22.2-2 ListBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X85AD5EF77EFD7451">22.2-3 SizeBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7BA42D03796ED4B3">22.2-4 IsSubsetBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap22.html#X8100080382AECFF9">22.3 <span class="Heading">Set Operations via Boolean Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7970BD3883C42D91">22.3-1 <span class="Heading">UnionBlist</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X86E1F8DE85E1EE1E">22.3-2 <span class="Heading">IntersectionBlist</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7D6FC2C58725708C">22.3-3 DifferenceBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap22.html#X8634D25D7B4C6151">22.4 <span class="Heading">Function that Modify Boolean Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X79815EB77CC8A389">22.4-1 UniteBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7C86C8D3853BE5EB">22.4-2 UniteBlistList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X84EB70D37EB275DF">22.4-3 IntersectBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7AA138407D5A3BAC">22.4-4 SubtractBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X830645EC846B2E3C">22.4-5 MeetBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7F14FF35786DAEF3">22.4-6 FlipBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X7E9F6C197A79098F">22.4-7 SetAllBlist</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X87ED45A88688AE8E">22.4-8 ClearAllBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap22.html#X7C71B225841DFC0F">22.5 <span class="Heading">More about Boolean Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap22.html#X8453ADDA810B4C03">22.5-1 IsBlistRep</a></span>
</div></div>
</div>

<h3>22 <span class="Heading">Boolean Lists</span></h3>

<p>This chapter describes boolean lists. A <em>boolean list</em> is a list that has no holes and contains only the boolean values <code class="keyw">true</code> and <code class="keyw">false</code> (see Chapter <a href="chap20.html#X787B4AB77A2F5E14"><span class="RefLink">20</span></a>). In function names we call boolean lists <em>blists</em> for brevity.</p>

<p><a id="X7E7832B0804221AE" name="X7E7832B0804221AE"></a></p>

<h4>22.1 <span class="Heading">IsBlist (Filter)</span></h4>

<p><a id="X7BE078187A08DCEA" name="X7BE078187A08DCEA"></a></p>

<h5>22.1-1 IsBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsBlist</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A boolean list (<q>blist</q>) is a list that has no holes and contains only <code class="keyw">true</code> and <code class="keyw">false</code>. Boolean lists can be represented in an efficient compacform, see <a href="chap22.html#X7C71B225841DFC0F"><span class="RefLink">22.5</span></a> for details.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlist( [ true, true, false, false ] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlist( [] );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlist( [false,,true] );  # has holes</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlist( [1,1,0,0] );      # contains not only boolean values</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlist( 17 );             # is not even a list</span>
false
</pre></div>

<p>Boolean lists are lists and all operations for lists are therefore applicable to boolean lists.</p>

<p>Boolean lists can be used in various ways, but maybe the most important application is their use for the description of <em>subsets</em> of finite sets. Suppose <span class="SimpleMath">set</span> is a finite set, represented as a list. Then a subset <span class="SimpleMath">sub</span> of <span class="SimpleMath">set</span> is represented by a boolean list <span class="SimpleMath">blist</span> of the same length as <span class="SimpleMath">set</span> such that <span class="SimpleMath">blist[i]</span> is <code class="keyw">true</code> if <span class="SimpleMath">set[i]</span> is in <span class="SimpleMath">sub</span>, and <code class="keyw">false</code> otherwise.</p>

<p><a id="X7CC745317FE54C14" name="X7CC745317FE54C14"></a></p>

<h4>22.2 <span class="Heading">Boolean Lists Representing Subsets</span></h4>

<p><a id="X7C597B2D87CA2E6E" name="X7C597B2D87CA2E6E"></a></p>

<h5>22.2-1 BlistList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BlistList</code>( <var class="Arg">list</var>, <var class="Arg">sub</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns a new boolean list that describes the list <var class="Arg">sub</var> as a sublist of the dense list <var class="Arg">list</var>. That is <code class="func">BlistList</code> returns a boolean list <span class="SimpleMath">blist</span> of the same length as <var class="Arg">list</var> such that <span class="SimpleMath">blist[i]</span> is <code class="keyw">true</code> if <var class="Arg">list</var><span class="SimpleMath">[i]</span> is in <var class="Arg">sub</var> and <code class="keyw">false</code> otherwise.</p>

<p><var class="Arg">list</var> need not be a proper set (see <a href="chap21.html#X80ABC25582343910"><span class="RefLink">21.19</span></a>), even though in this case <code class="func">BlistList</code> is most efficient. In particular <var class="Arg">list</var> may contain duplicates. <var class="Arg">sub</var> need not be a proper sublist of <var class="Arg">list</var>, i.e., <var class="Arg">sub</var> may contain elements that are not in <var class="Arg">list</var>. Those elements of course have no influence on the result of <code class="func">BlistList</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BlistList( [1..10], [2,3,5,7] );</span>
[ false, true, true, false, true, false, true, false, false, false ]
<span class="GAPprompt">gap></span> <span class="GAPinput">BlistList( [1,2,3,4,5,2,8,6,4,10], [4,8,9,16] );</span>
[ false, false, false, true, false, false, true, false, true, false ]
</pre></div>

<p>See also <code class="func">UniteBlistList</code> (<a href="chap22.html#X7C86C8D3853BE5EB"><span class="RefLink">22.4-2</span></a>).</p>

<p><a id="X874BEF63785AB439" name="X874BEF63785AB439"></a></p>

<h5>22.2-2 ListBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ListBlist</code>( <var class="Arg">list</var>, <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the sublist <span class="SimpleMath">sub</span> of the list <var class="Arg">list</var>, which must have no holes, represented by the boolean list <var class="Arg">blist</var>, which must have the same length as <var class="Arg">list</var>.</p>

<p><span class="SimpleMath">sub</span> contains the element <var class="Arg">list</var><span class="SimpleMath">[i]</span> if <var class="Arg">blist</var><span class="SimpleMath">[i]</span> is <code class="keyw">true</code> and does not contain the element if <var class="Arg">blist</var><span class="SimpleMath">[i]</span> is <code class="keyw">false</code>. The order of the elements in <span class="SimpleMath">sub</span> is the same as the order of the corresponding elements in <var class="Arg">list</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListBlist([1..8],[false,true,true,true,true,false,true,true]);</span>
[ 2, 3, 4, 5, 7, 8 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">ListBlist( [1,2,3,4,5,2,8,6,4,10],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[false,false,false,true,false,false,true,false,true,false] );</span>
[ 4, 8, 4 ]
</pre></div>

<p><a id="X85AD5EF77EFD7451" name="X85AD5EF77EFD7451"></a></p>

<h5>22.2-3 SizeBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SizeBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of entries of the boolean list <var class="Arg">blist</var> that are <code class="keyw">true</code>. This is the size of the subset represented by the boolean list <var class="Arg">blist</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">SizeBlist( [ false, true, false, true, false ] );</span>
2
</pre></div>

<p><a id="X7BA42D03796ED4B3" name="X7BA42D03796ED4B3"></a></p>

<h5>22.2-4 IsSubsetBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsSubsetBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the boolean list <var class="Arg">blist2</var> is a subset of the boolean list <var class="Arg">blist1</var>, which must have equal length, and <code class="keyw">false</code> otherwise. <var class="Arg">blist2</var> is a subset of <var class="Arg">blist1</var> if <var class="Arg">blist1</var><span class="SimpleMath">[i] =</span> <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">or</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> for all <span class="SimpleMath">i</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSubsetBlist( blist1, blist2 );</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSubsetBlist( blist1, blist2 );</span>
true
</pre></div>

<p><a id="X8100080382AECFF9" name="X8100080382AECFF9"></a></p>

<h4>22.3 <span class="Heading">Set Operations via Boolean Lists</span></h4>

<p><a id="X7970BD3883C42D91" name="X7970BD3883C42D91"></a></p>

<h5>22.3-1 <span class="Heading">UnionBlist</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UnionBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var>[, <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UnionBlist</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In the first form <code class="func">UnionBlist</code> returns the union of the boolean lists <var class="Arg">blist1</var>, <var class="Arg">blist2</var>, etc., which must have equal length. The <em>union</em> is a new boolean list that contains at position <span class="SimpleMath">i</span> the value <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">or</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> <code class="keyw">or</code> <span class="SimpleMath">...</span>.</p>

<p>The second form takes the union of all blists (which as for the first form must have equal length) in the list <var class="Arg">list</var>.</p>

<p><a id="X86E1F8DE85E1EE1E" name="X86E1F8DE85E1EE1E"></a></p>

<h5>22.3-2 <span class="Heading">IntersectionBlist</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IntersectionBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var>[, <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IntersectionBlist</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In the first form <code class="func">IntersectionBlist</code> returns the intersection of the boolean lists <var class="Arg">blist1</var>, <var class="Arg">blist2</var>, etc., which must have equal length. The <em>intersection</em> is a new blist that contains at position <span class="SimpleMath">i</span> the value <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">and</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> <code class="keyw">and</code> <span class="SimpleMath">...</span>.</p>

<p>In the second form <var class="Arg">list</var> must be a list of boolean lists <var class="Arg">blist1</var>, <var class="Arg">blist2</var>, etc., which must have equal length, and <code class="func">IntersectionBlist</code> returns the intersection of those boolean lists.</p>

<p><a id="X7D6FC2C58725708C" name="X7D6FC2C58725708C"></a></p>

<h5>22.3-3 DifferenceBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DifferenceBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the asymmetric set difference of the two boolean lists <var class="Arg">blist1</var> and <var class="Arg">blist2</var>, which must have equal length. The <em>asymmetric set difference</em> is a new boolean list that contains at position <span class="SimpleMath">i</span> the value <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">and</code> <code class="keyw">not</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">UnionBlist( blist1, blist2 );</span>
[ true, true, true, false ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IntersectionBlist( blist1, blist2 );</span>
[ true, false, false, false ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DifferenceBlist( blist1, blist2 );</span>
[ false, true, false, false ]
</pre></div>

<p><a id="X8634D25D7B4C6151" name="X8634D25D7B4C6151"></a></p>

<h4>22.4 <span class="Heading">Function that Modify Boolean Lists</span></h4>

<p><a id="X79815EB77CC8A389" name="X79815EB77CC8A389"></a></p>

<h5>22.4-1 UniteBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UniteBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">UniteBlist</code> unites the boolean list <var class="Arg">blist1</var> with the boolean list <var class="Arg">blist2</var>, which must have the same length. This is equivalent to assigning <var class="Arg">blist1</var><span class="SimpleMath">[i] :=</span> <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">or</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> for all <span class="SimpleMath">i</span>.</p>

<p><code class="func">UniteBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">UniteBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ true, true, true, false ]
</pre></div>

<p>The function <code class="func">UnionBlist</code> (<a href="chap22.html#X7970BD3883C42D91"><span class="RefLink">22.3-1</span></a>) is the nondestructive counterpart to <code class="func">UniteBlist</code>.</p>

<p><a id="X7C86C8D3853BE5EB" name="X7C86C8D3853BE5EB"></a></p>

<h5>22.4-2 UniteBlistList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UniteBlistList</code>( <var class="Arg">list</var>, <var class="Arg">blist</var>, <var class="Arg">sub</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>works like <code class="code">UniteBlist(<var class="Arg">blist</var>,BlistList(<var class="Arg">list</var>,<var class="Arg">sub</var>))</code>. As no intermediate blist is created, the performance is better than the separate function calls.</p>

<p><a id="X84EB70D37EB275DF" name="X84EB70D37EB275DF"></a></p>

<h5>22.4-3 IntersectBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IntersectBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>intersects the boolean list <var class="Arg">blist1</var> with the boolean list <var class="Arg">blist2</var>, which must have the same length. This is equivalent to assigning <var class="Arg">blist1</var><span class="SimpleMath">[i]:=</span> <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">and</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> for all <span class="SimpleMath">i</span>.</p>

<p><code class="func">IntersectBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IntersectBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ true, false, false, false ]
</pre></div>

<p>The function <code class="func">IntersectionBlist</code> (<a href="chap22.html#X86E1F8DE85E1EE1E"><span class="RefLink">22.3-2</span></a>) is the nondestructive counterpart to <code class="func">IntersectBlist</code>.</p>

<p><a id="X7AA138407D5A3BAC" name="X7AA138407D5A3BAC"></a></p>

<h5>22.4-4 SubtractBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SubtractBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>subtracts the boolean list <var class="Arg">blist2</var> from the boolean list <var class="Arg">blist1</var>, which must have equal length. This is equivalent to assigning <var class="Arg">blist1</var><span class="SimpleMath">[i]:=</span> <var class="Arg">blist1</var><span class="SimpleMath">[i]</span> <code class="keyw">and</code> <code class="keyw">not</code> <var class="Arg">blist2</var><span class="SimpleMath">[i]</span> for all <span class="SimpleMath">i</span>.</p>

<p><code class="func">SubtractBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">SubtractBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ false, true, false, false ]
</pre></div>

<p>The function <code class="func">DifferenceBlist</code> (<a href="chap22.html#X7D6FC2C58725708C"><span class="RefLink">22.3-3</span></a>) is the nondestructive counterpart to <code class="func">SubtractBlist</code>.</p>

<p><a id="X830645EC846B2E3C" name="X830645EC846B2E3C"></a></p>

<h5>22.4-5 MeetBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MeetBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns <code class="keyw">true</code> if there is a position at which both <var class="Arg">blist1</var> and <var class="Arg">blist2</var> contain <code class="keyw">true</code>, and <code class="keyw">false</code> otherwise. It is equivalent to, but faster than <code class="code">SizeBlist(IntersectionBlist(blist1, blist2)) <> 0</code>. An error is thrown if the lists do not have the same length.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">MeetBlist( blist1, blist2 );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">FlipBlist( blist1 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">MeetBlist( blist1, blist2 );</span>
false
</pre></div>

<p><a id="X7F14FF35786DAEF3" name="X7F14FF35786DAEF3"></a></p>

<h5>22.4-6 FlipBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ FlipBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Changes every entry in <var class="Arg">blist</var> that equals <code class="keyw">true</code> to <code class="keyw">false</code> and vice versa. If <code class="code">blist1</code> and <code class="code">blist2</code> are boolean lists with equal length and every value in <code class="code">blist2</code> is <code class="keyw">true</code>, then <code class="code">FlipBlist( blist1 )</code> is equivalent to <code class="code">SubtractBlist( blist2, blist1 ); blist1 := blist2;</code> but <code class="code">FlipBlist</code> is faster, and simpler to type.</p>

<p><code class="func">FlipBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">SubtractBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ false, true, false, true ]
<span class="GAPprompt">gap></span> <span class="GAPinput">FlipBlist( blist2 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2;</span>
[ false, true, false, true ]
</pre></div>

<p><a id="X7E9F6C197A79098F" name="X7E9F6C197A79098F"></a></p>

<h5>22.4-7 SetAllBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SetAllBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Changes every entry in <var class="Arg">blist</var> to <code class="keyw">true</code>. If <code class="code">blist1</code> and <code class="code">blist2</code> are boolean lists with equal length and every value in <code class="code">blist2</code> is <code class="keyw">true</code>, then <code class="code">SetAllBlist( blist1 )</code> is equivalent to <code class="code">UniteBlist( blist1, blist2 );</code> but is faster, and simpler to type.</p>

<p><code class="func">SetAllBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">SetAllBlist( blist1 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ true, true, true, true ]
<span class="GAPprompt">gap></span> <span class="GAPinput">SetAllBlist(blist2);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2;</span>
[ true, true, true, true ]
</pre></div>

<p><a id="X87ED45A88688AE8E" name="X87ED45A88688AE8E"></a></p>

<h5>22.4-8 ClearAllBlist</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ClearAllBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Changes every entry in <var class="Arg">blist</var> to <code class="keyw">false</code>. If <code class="code">blist1</code> and <code class="code">blist2</code> are boolean lists with equal length and every value in <code class="code">blist2</code> is <code class="keyw">false</code>, then <code class="code">ClearAllBlist( blist1 )</code> is equivalent to <code class="code">IntersectBlist( blist1, blist2 );</code> but is faster, and simpler to type.</p>

<p><code class="func">ClearAllBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ClearAllBlist( blist1 );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist1;</span>
[ false, false, false, false ]
<span class="GAPprompt">gap></span> <span class="GAPinput">ClearAllBlist(blist2);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">blist2;</span>
[ false, false, false, false ]
</pre></div>

<p><a id="X7C71B225841DFC0F" name="X7C71B225841DFC0F"></a></p>

<h4>22.5 <span class="Heading">More about Boolean Lists</span></h4>

<p>We defined a boolean list as a list that has no holes and contains only <code class="keyw">true</code> and <code class="keyw">false</code>. There is a special internal representation for boolean lists that needs only 1 bit for each entry. This bit is set if the entry is <code class="keyw">true</code> and reset if the entry is <code class="keyw">false</code>. This representation is of course much more compact than the ordinary representation of lists, which needs 32 or 64 bits per entry.</p>

<p>Not every boolean list is represented in this compact representation. It would be too much work to test every time a list is changed, whether this list has become a boolean list. This section tells you under which circumstances a boolean list is represented in the compact representation, so you can write your functions in such a way that you make best use of the compact representation.</p>

<p>If a dense list containing only <code class="keyw">true</code> and <code class="keyw">false</code> is read, it is stored in the compact representation. Furthermore, the results of <code class="func">BlistList</code> (<a href="chap22.html#X7C597B2D87CA2E6E"><span class="RefLink">22.2-1</span></a>), <code class="func">UnionBlist</code> (<a href="chap22.html#X7970BD3883C42D91"><span class="RefLink">22.3-1</span></a>), <code class="func">IntersectionBlist</code> (<a href="chap22.html#X86E1F8DE85E1EE1E"><span class="RefLink">22.3-2</span></a>) and <code class="func">DifferenceBlist</code> (<a href="chap22.html#X7D6FC2C58725708C"><span class="RefLink">22.3-3</span></a>) are known to be boolean lists by construction, and thus are represented in the compact representation upon creation.</p>

<p>If an argument of <code class="func">IsSubsetBlist</code> (<a href="chap22.html#X7BA42D03796ED4B3"><span class="RefLink">22.2-4</span></a>), <code class="func">ListBlist</code> (<a href="chap22.html#X874BEF63785AB439"><span class="RefLink">22.2-2</span></a>), <code class="func">UnionBlist</code> (<a href="chap22.html#X7970BD3883C42D91"><span class="RefLink">22.3-1</span></a>), <code class="func">IntersectionBlist</code> (<a href="chap22.html#X86E1F8DE85E1EE1E"><span class="RefLink">22.3-2</span></a>), <code class="func">DifferenceBlist</code> (<a href="chap22.html#X7D6FC2C58725708C"><span class="RefLink">22.3-3</span></a>), <code class="func">UniteBlist</code> (<a href="chap22.html#X79815EB77CC8A389"><span class="RefLink">22.4-1</span></a>), <code class="func">IntersectBlist</code> (<a href="chap22.html#X84EB70D37EB275DF"><span class="RefLink">22.4-3</span></a>) and <code class="func">SubtractBlist</code> (<a href="chap22.html#X7AA138407D5A3BAC"><span class="RefLink">22.4-4</span></a>) is a list represented in the ordinary representation, it is tested to see if it is in fact a boolean list. If it is not, an error is signalled. If it is, the representation of the list is changed to the compact representation.</p>

<p>If you change a boolean list that is represented in the compact representation by assignment (see <a href="chap21.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>) or <code class="func">Add</code> (<a href="chap21.html#X795EC9D67E34DAB0"><span class="RefLink">21.4-2</span></a>) in such a way that the list remains a boolean list it will remain represented in the compact representation. Note that changing a list that is not represented in the compact representation, whether it is a boolean list or not, in such a way that the resulting list becomes a boolean list, will never change the representation of the list.</p>

<p><a id="X8453ADDA810B4C03" name="X8453ADDA810B4C03"></a></p>

<h5>22.5-1 IsBlistRep</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsBlistRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">( representation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ConvertToBlistRep</code>( <var class="Arg">blist</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: <code class="keyw">true</code> or <code class="keyw">false</code></p>

<p>The first function is a filter that returns <code class="keyw">true</code> if the object <var class="Arg">obj</var> is a boolean list in compact representation and <code class="keyw">false</code> otherwise, see <a href="chap22.html#X7C71B225841DFC0F"><span class="RefLink">22.5</span></a>.</p>

<p>The second function converts the object <var class="Arg">blist</var> to a boolean list in compact representation and returns <code class="keyw">true</code> if this is possible. Otherwise <var class="Arg">blist</var> is unchanged and <code class="keyw">false</code> is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [true, false, true];</span>
[ true, false, true ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlistRep(l);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">l := [true, false, 1];</span>
[ true, false, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">l[3] := false;</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBlistRep(l);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ConvertToBlistRep(l);</span>
true
</pre></div>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap21.html">[Previous Chapter]</a>    <a href="chap23.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

92%


¤ Dauer der Verarbeitung: 0.20 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.