Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /usr/share/gap/doc/ref/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : //usr/share/gap/doc/ref/chap22_mj.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>
<script type="text/javascript"
  src="mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<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_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chap12_mj.html">12</a>  <a href="chap13_mj.html">13</a>  <a href="chap14_mj.html">14</a>  <a href="chap15_mj.html">15</a>  <a href="chap16_mj.html">16</a>  <a href="chap17_mj.html">17</a>  <a href="chap18_mj.html">18</a>  <a href="chap19_mj.html">19</a>  <a href="chap20_mj.html">20</a>  <a href="chap21_mj.html">21</a>  <a href="chap22_mj.html">22</a>  <a href="chap23_mj.html">23</a>  <a href="chap24_mj.html">24</a>  <a href="chap25_mj.html">25</a>  <a href="chap26_mj.html">26</a>  <a href="chap27_mj.html">27</a>  <a href="chap28_mj.html">28</a>  <a href="chap29_mj.html">29</a>  <a href="chap30_mj.html">30</a>  <a href="chap31_mj.html">31</a>  <a href="chap32_mj.html">32</a>  <a href="chap33_mj.html">33</a>  <a href="chap34_mj.html">34</a>  <a href="chap35_mj.html">35</a>  <a href="chap36_mj.html">36</a>  <a href="chap37_mj.html">37</a>  <a href="chap38_mj.html">38</a>  <a href="chap39_mj.html">39</a>  <a href="chap40_mj.html">40</a>  <a href="chap41_mj.html">41</a>  <a href="chap42_mj.html">42</a>  <a href="chap43_mj.html">43</a>  <a href="chap44_mj.html">44</a>  <a href="chap45_mj.html">45</a>  <a href="chap46_mj.html">46</a>  <a href="chap47_mj.html">47</a>  <a href="chap48_mj.html">48</a>  <a href="chap49_mj.html">49</a>  <a href="chap50_mj.html">50</a>  <a href="chap51_mj.html">51</a>  <a href="chap52_mj.html">52</a>  <a href="chap53_mj.html">53</a>  <a href="chap54_mj.html">54</a>  <a href="chap55_mj.html">55</a>  <a href="chap56_mj.html">56</a>  <a href="chap57_mj.html">57</a>  <a href="chap58_mj.html">58</a>  <a href="chap59_mj.html">59</a>  <a href="chap60_mj.html">60</a>  <a href="chap61_mj.html">61</a>  <a href="chap62_mj.html">62</a>  <a href="chap63_mj.html">63</a>  <a href="chap64_mj.html">64</a>  <a href="chap65_mj.html">65</a>  <a href="chap66_mj.html">66</a>  <a href="chap67_mj.html">67</a>  <a href="chap68_mj.html">68</a>  <a href="chap69_mj.html">69</a>  <a href="chap70_mj.html">70</a>  <a href="chap71_mj.html">71</a>  <a href="chap72_mj.html">72</a>  <a href="chap73_mj.html">73</a>  <a href="chap74_mj.html">74</a>  <a href="chap75_mj.html">75</a>  <a href="chap76_mj.html">76</a>  <a href="chap77_mj.html">77</a>  <a href="chap78_mj.html">78</a>  <a href="chap79_mj.html">79</a>  <a href="chap80_mj.html">80</a>  <a href="chap81_mj.html">81</a>  <a href="chap82_mj.html">82</a>  <a href="chap83_mj.html">83</a>  <a href="chap84_mj.html">84</a>  <a href="chap85_mj.html">85</a>  <a href="chap86_mj.html">86</a>  <a href="chap87_mj.html">87</a>  <a href="chapBib_mj.html">Bib</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<div class="chlinkprevnexttop">&nbsp;<a href="chap0_mj.html">[Top of Book]</a>&nbsp;  <a href="chap0_mj.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap21_mj.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap23_mj.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap22.html">[MathJax off]</a></p>
<p><a id="X7AC531DD79B6938E" name="X7AC531DD79B6938E"></a></p>
<div class="ChapSects"><a href="chap22_mj.html#X7AC531DD79B6938E">22 <span class="Heading">Boolean Lists</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22_mj.html#X7E7832B0804221AE">22.1 <span class="Heading">IsBlist (Filter)</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7BE078187A08DCEA">22.1-1 IsBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22_mj.html#X7CC745317FE54C14">22.2 <span class="Heading">Boolean Lists Representing Subsets</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7C597B2D87CA2E6E">22.2-1 BlistList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X874BEF63785AB439">22.2-2 ListBlist</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X85AD5EF77EFD7451">22.2-3 SizeBlist</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7BA42D03796ED4B3">22.2-4 IsSubsetBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22_mj.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">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7970BD3883C42D91">22.3-1 <span class="Heading">UnionBlist</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X86E1F8DE85E1EE1E">22.3-2 <span class="Heading">IntersectionBlist</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7D6FC2C58725708C">22.3-3 DifferenceBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22_mj.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">&nbsp;&nbsp;</span><a href="chap22_mj.html#X79815EB77CC8A389">22.4-1 UniteBlist</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7C86C8D3853BE5EB">22.4-2 UniteBlistList</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X84EB70D37EB275DF">22.4-3 IntersectBlist</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.html#X7AA138407D5A3BAC">22.4-4 SubtractBlist</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22_mj.html#X7C71B225841DFC0F">22.5 <span class="Heading">More about Boolean Lists</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22_mj.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_mj.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">&#8227; IsBlist</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
<p>A boolean list ("blist") 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 compact form, see <a href="chap22_mj.html#X7C71B225841DFC0F"><span class="RefLink">22.5</span></a> for details.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [ true, true, false, false ] );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [] );</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [false,,true] );  # has holes</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [1,1,0,0] );      # contains not only boolean values</span>
false
<span class="GAPprompt">gap&gt;</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">&#8227; BlistList</code>( <var class="Arg">list</var>, <var class="Arg">sub</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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_mj.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&gt;</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&gt;</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_mj.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">&#8227; ListBlist</code>( <var class="Arg">list</var>, <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</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&gt;</span> <span class="GAPinput">ListBlist( [1,2,3,4,5,2,8,6,4,10],</span>
<span class="GAPprompt">&gt;</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">&#8227; SizeBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</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">&#8227; IsSubsetBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubsetBlist( blist1, blist2 );</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, false, false ];;</span>
<span class="GAPprompt">gap&gt;</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">&#8227; UnionBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var>[, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; UnionBlist</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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">\(\ldots\)</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">&#8227; IntersectionBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var>[, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IntersectionBlist</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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">\(\ldots\)</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">&#8227; DifferenceBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">UnionBlist( blist1, blist2 );</span>
[ true, true, true, false ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IntersectionBlist( blist1, blist2 );</span>
[ true, false, false, false ]
<span class="GAPprompt">gap&gt;</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">&#8227; UniteBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">UniteBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
[ true, true, true, false ]
</pre></div>

<p>The function <code class="func">UnionBlist</code> (<a href="chap22_mj.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">&#8227; UniteBlistList</code>( <var class="Arg">list</var>, <var class="Arg">blist</var>, <var class="Arg">sub</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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">&#8227; IntersectBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IntersectBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
[ true, false, false, false ]
</pre></div>

<p>The function <code class="func">IntersectionBlist</code> (<a href="chap22_mj.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">&#8227; SubtractBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SubtractBlist( blist1, blist2 );</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
[ false, true, false, false ]
</pre></div>

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

<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_mj.html#X7C597B2D87CA2E6E"><span class="RefLink">22.2-1</span></a>), <code class="func">UnionBlist</code> (<a href="chap22_mj.html#X7970BD3883C42D91"><span class="RefLink">22.3-1</span></a>), <code class="func">IntersectionBlist</code> (<a href="chap22_mj.html#X86E1F8DE85E1EE1E"><span class="RefLink">22.3-2</span></a>) and <code class="func">DifferenceBlist</code> (<a href="chap22_mj.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_mj.html#X7BA42D03796ED4B3"><span class="RefLink">22.2-4</span></a>), <code class="func">ListBlist</code> (<a href="chap22_mj.html#X874BEF63785AB439"><span class="RefLink">22.2-2</span></a>), <code class="func">UnionBlist</code> (<a href="chap22_mj.html#X7970BD3883C42D91"><span class="RefLink">22.3-1</span></a>), <code class="func">IntersectionBlist</code> (<a href="chap22_mj.html#X86E1F8DE85E1EE1E"><span class="RefLink">22.3-2</span></a>), <code class="func">DifferenceBlist</code> (<a href="chap22_mj.html#X7D6FC2C58725708C"><span class="RefLink">22.3-3</span></a>), <code class="func">UniteBlist</code> (<a href="chap22_mj.html#X79815EB77CC8A389"><span class="RefLink">22.4-1</span></a>), <code class="func">IntersectBlist</code> (<a href="chap22_mj.html#X84EB70D37EB275DF"><span class="RefLink">22.4-3</span></a>) and <code class="func">SubtractBlist</code> (<a href="chap22_mj.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_mj.html#X8611EF768210625B"><span class="RefLink">21.4</span></a>) or <code class="func">Add</code> (<a href="chap21_mj.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">&#8227; IsBlistRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertToBlistRep</code>( <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</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_mj.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&gt;</span> <span class="GAPinput">l := [true, false, true];</span>
[ true, false, true ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlistRep(l);</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l := [true, false, 1]; </span>
[ true, false, 1 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l[3] := false;</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlistRep(l);</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ConvertToBlistRep(l);</span>
true
</pre></div>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0_mj.html">[Top of Book]</a>&nbsp;  <a href="chap0_mj.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap21_mj.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap23_mj.html">[Next Chapter]</a>&nbsp;  </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chap12_mj.html">12</a>  <a href="chap13_mj.html">13</a>  <a href="chap14_mj.html">14</a>  <a href="chap15_mj.html">15</a>  <a href="chap16_mj.html">16</a>  <a href="chap17_mj.html">17</a>  <a href="chap18_mj.html">18</a>  <a href="chap19_mj.html">19</a>  <a href="chap20_mj.html">20</a>  <a href="chap21_mj.html">21</a>  <a href="chap22_mj.html">22</a>  <a href="chap23_mj.html">23</a>  <a href="chap24_mj.html">24</a>  <a href="chap25_mj.html">25</a>  <a href="chap26_mj.html">26</a>  <a href="chap27_mj.html">27</a>  <a href="chap28_mj.html">28</a>  <a href="chap29_mj.html">29</a>  <a href="chap30_mj.html">30</a>  <a href="chap31_mj.html">31</a>  <a href="chap32_mj.html">32</a>  <a href="chap33_mj.html">33</a>  <a href="chap34_mj.html">34</a>  <a href="chap35_mj.html">35</a>  <a href="chap36_mj.html">36</a>  <a href="chap37_mj.html">37</a>  <a href="chap38_mj.html">38</a>  <a href="chap39_mj.html">39</a>  <a href="chap40_mj.html">40</a>  <a href="chap41_mj.html">41</a>  <a href="chap42_mj.html">42</a>  <a href="chap43_mj.html">43</a>  <a href="chap44_mj.html">44</a>  <a href="chap45_mj.html">45</a>  <a href="chap46_mj.html">46</a>  <a href="chap47_mj.html">47</a>  <a href="chap48_mj.html">48</a>  <a href="chap49_mj.html">49</a>  <a href="chap50_mj.html">50</a>  <a href="chap51_mj.html">51</a>  <a href="chap52_mj.html">52</a>  <a href="chap53_mj.html">53</a>  <a href="chap54_mj.html">54</a>  <a href="chap55_mj.html">55</a>  <a href="chap56_mj.html">56</a>  <a href="chap57_mj.html">57</a>  <a href="chap58_mj.html">58</a>  <a href="chap59_mj.html">59</a>  <a href="chap60_mj.html">60</a>  <a href="chap61_mj.html">61</a>  <a href="chap62_mj.html">62</a>  <a href="chap63_mj.html">63</a>  <a href="chap64_mj.html">64</a>  <a href="chap65_mj.html">65</a>  <a href="chap66_mj.html">66</a>  <a href="chap67_mj.html">67</a>  <a href="chap68_mj.html">68</a>  <a href="chap69_mj.html">69</a>  <a href="chap70_mj.html">70</a>  <a href="chap71_mj.html">71</a>  <a href="chap72_mj.html">72</a>  <a href="chap73_mj.html">73</a>  <a href="chap74_mj.html">74</a>  <a href="chap75_mj.html">75</a>  <a href="chap76_mj.html">76</a>  <a href="chap77_mj.html">77</a>  <a href="chap78_mj.html">78</a>  <a href="chap79_mj.html">79</a>  <a href="chap80_mj.html">80</a>  <a href="chap81_mj.html">81</a>  <a href="chap82_mj.html">82</a>  <a href="chap83_mj.html">83</a>  <a href="chap84_mj.html">84</a>  <a href="chap85_mj.html">85</a>  <a href="chap86_mj.html">86</a>  <a href="chap87_mj.html">87</a>  <a href="chapBib_mj.html">Bib</a>  <a href="chapInd_mj.html">Ind</a>  </div>

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

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net