Debian Codegraph @

doc/ref/chap22.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <head>
8 <title>GAP (ref) - Chapter 22: Boolean Lists</title>
9 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
10 <meta name="generator" content="GAPDoc2HTML" />
11 <link rel="stylesheet" type="text/css" href="manual.css" />
12 <script src="manual.js" type="text/javascript"></script>
13 <script type="text/javascript">overwriteStyle();</script>
14 </head>
15 <body class="chap22" onload="jscontent()">
16
17
18 <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>
19
20 <div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap21.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap23.html">[Next Chapter]</a>&nbsp; </div>
21
22 <p id="mathjaxlink" class="pcenter"><a href="chap22_mj.html">[MathJax on]</a></p>
23 <p><a id="X7AC531DD79B6938E" name="X7AC531DD79B6938E"></a></p>
24 <div class="ChapSects"><a href="chap22.html#X7AC531DD79B6938E">22 <span class="Heading">Boolean Lists</span></a>
25 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22.html#X7E7832B0804221AE">22.1 <span class="Heading">IsBlist (Filter)</span></a>
26 </span>
27 <div class="ContSSBlock">
28 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7BE078187A08DCEA">22.1-1 IsBlist</a></span>
29 </div></div>
30 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22.html#X7CC745317FE54C14">22.2 <span class="Heading">Boolean Lists Representing Subsets</span></a>
31 </span>
32 <div class="ContSSBlock">
33 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7C597B2D87CA2E6E">22.2-1 BlistList</a></span>
34 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X874BEF63785AB439">22.2-2 ListBlist</a></span>
35 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X85AD5EF77EFD7451">22.2-3 SizeBlist</a></span>
36 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7BA42D03796ED4B3">22.2-4 IsSubsetBlist</a></span>
37 </div></div>
38 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22.html#X8100080382AECFF9">22.3 <span class="Heading">Set Operations via Boolean Lists</span></a>
39 </span>
40 <div class="ContSSBlock">
41 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7970BD3883C42D91">22.3-1 <span class="Heading">UnionBlist</span></a>
42 </span>
43 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X86E1F8DE85E1EE1E">22.3-2 <span class="Heading">IntersectionBlist</span></a>
44 </span>
45 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7D6FC2C58725708C">22.3-3 DifferenceBlist</a></span>
46 </div></div>
47 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22.html#X8634D25D7B4C6151">22.4 <span class="Heading">Function that Modify Boolean Lists</span></a>
48 </span>
49 <div class="ContSSBlock">
50 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X79815EB77CC8A389">22.4-1 UniteBlist</a></span>
51 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7C86C8D3853BE5EB">22.4-2 UniteBlistList</a></span>
52 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X84EB70D37EB275DF">22.4-3 IntersectBlist</a></span>
53 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7AA138407D5A3BAC">22.4-4 SubtractBlist</a></span>
54 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X830645EC846B2E3C">22.4-5 MeetBlist</a></span>
55 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7F14FF35786DAEF3">22.4-6 FlipBlist</a></span>
56 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X7E9F6C197A79098F">22.4-7 SetAllBlist</a></span>
57 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X87ED45A88688AE8E">22.4-8 ClearAllBlist</a></span>
58 </div></div>
59 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap22.html#X7C71B225841DFC0F">22.5 <span class="Heading">More about Boolean Lists</span></a>
60 </span>
61 <div class="ContSSBlock">
62 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap22.html#X8453ADDA810B4C03">22.5-1 IsBlistRep</a></span>
63 </div></div>
64 </div>
65
66 <h3>22 <span class="Heading">Boolean Lists</span></h3>
67
68 <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>
69
70 <p><a id="X7E7832B0804221AE" name="X7E7832B0804221AE"></a></p>
71
72 <h4>22.1 <span class="Heading">IsBlist (Filter)</span></h4>
73
74 <p><a id="X7BE078187A08DCEA" name="X7BE078187A08DCEA"></a></p>
75
76 <h5>22.1-1 IsBlist</h5>
77
78 <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>
79 <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 compact form, see <a href="chap22.html#X7C71B225841DFC0F"><span class="RefLink">22.5</span></a> for details.</p>
80
81
82 <div class="example"><pre>
83 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [ true, true, false, false ] );</span>
84 true
85 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [] );</span>
86 true
87 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [false,,true] ); # has holes</span>
88 false
89 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( [1,1,0,0] ); # contains not only boolean values</span>
90 false
91 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlist( 17 ); # is not even a list</span>
92 false
93 </pre></div>
94
95 <p>Boolean lists are lists and all operations for lists are therefore applicable to boolean lists.</p>
96
97 <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>
98
99 <p><a id="X7CC745317FE54C14" name="X7CC745317FE54C14"></a></p>
100
101 <h4>22.2 <span class="Heading">Boolean Lists Representing Subsets</span></h4>
102
103 <p><a id="X7C597B2D87CA2E6E" name="X7C597B2D87CA2E6E"></a></p>
104
105 <h5>22.2-1 BlistList</h5>
106
107 <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>
108 <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>
109
110 <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>
111
112
113 <div class="example"><pre>
114 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">BlistList( [1..10], [2,3,5,7] );</span>
115 [ false, true, true, false, true, false, true, false, false, false ]
116 <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>
117 [ false, false, false, true, false, false, true, false, true, false ]
118 </pre></div>
119
120 <p>See also <code class="func">UniteBlistList</code> (<a href="chap22.html#X7C86C8D3853BE5EB"><span class="RefLink">22.4-2</span></a>).</p>
121
122 <p><a id="X874BEF63785AB439" name="X874BEF63785AB439"></a></p>
123
124 <h5>22.2-2 ListBlist</h5>
125
126 <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>
127 <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>
128
129 <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>
130
131
132 <div class="example"><pre>
133 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ListBlist([1..8],[false,true,true,true,true,false,true,true]);</span>
134 [ 2, 3, 4, 5, 7, 8 ]
135 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ListBlist( [1,2,3,4,5,2,8,6,4,10],</span>
136 <span class="GAPprompt">&gt;</span> <span class="GAPinput">[false,false,false,true,false,false,true,false,true,false] );</span>
137 [ 4, 8, 4 ]
138 </pre></div>
139
140 <p><a id="X85AD5EF77EFD7451" name="X85AD5EF77EFD7451"></a></p>
141
142 <h5>22.2-3 SizeBlist</h5>
143
144 <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>
145 <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>
146
147
148 <div class="example"><pre>
149 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SizeBlist( [ false, true, false, true, false ] );</span>
150 2
151 </pre></div>
152
153 <p><a id="X7BA42D03796ED4B3" name="X7BA42D03796ED4B3"></a></p>
154
155 <h5>22.2-4 IsSubsetBlist</h5>
156
157 <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>
158 <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>
159
160
161 <div class="example"><pre>
162 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
163 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
164 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubsetBlist( blist1, blist2 );</span>
165 false
166 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, false, false ];;</span>
167 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsSubsetBlist( blist1, blist2 );</span>
168 true
169 </pre></div>
170
171 <p><a id="X8100080382AECFF9" name="X8100080382AECFF9"></a></p>
172
173 <h4>22.3 <span class="Heading">Set Operations via Boolean Lists</span></h4>
174
175 <p><a id="X7970BD3883C42D91" name="X7970BD3883C42D91"></a></p>
176
177 <h5>22.3-1 <span class="Heading">UnionBlist</span></h5>
178
179 <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>
180 <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>
181 <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>
182
183 <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>
184
185 <p><a id="X86E1F8DE85E1EE1E" name="X86E1F8DE85E1EE1E"></a></p>
186
187 <h5>22.3-2 <span class="Heading">IntersectionBlist</span></h5>
188
189 <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>
190 <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>
191 <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>
192
193 <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>
194
195 <p><a id="X7D6FC2C58725708C" name="X7D6FC2C58725708C"></a></p>
196
197 <h5>22.3-3 DifferenceBlist</h5>
198
199 <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>
200 <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>
201
202
203 <div class="example"><pre>
204 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
205 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
206 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">UnionBlist( blist1, blist2 );</span>
207 [ true, true, true, false ]
208 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IntersectionBlist( blist1, blist2 );</span>
209 [ true, false, false, false ]
210 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">DifferenceBlist( blist1, blist2 );</span>
211 [ false, true, false, false ]
212 </pre></div>
213
214 <p><a id="X8634D25D7B4C6151" name="X8634D25D7B4C6151"></a></p>
215
216 <h4>22.4 <span class="Heading">Function that Modify Boolean Lists</span></h4>
217
218 <p><a id="X79815EB77CC8A389" name="X79815EB77CC8A389"></a></p>
219
220 <h5>22.4-1 UniteBlist</h5>
221
222 <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>
223 <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>
224
225 <p><code class="func">UniteBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>
226
227
228 <div class="example"><pre>
229 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
230 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
231 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">UniteBlist( blist1, blist2 );</span>
232 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
233 [ true, true, true, false ]
234 </pre></div>
235
236 <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>
237
238 <p><a id="X7C86C8D3853BE5EB" name="X7C86C8D3853BE5EB"></a></p>
239
240 <h5>22.4-2 UniteBlistList</h5>
241
242 <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>
243 <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>
244
245 <p><a id="X84EB70D37EB275DF" name="X84EB70D37EB275DF"></a></p>
246
247 <h5>22.4-3 IntersectBlist</h5>
248
249 <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>
250 <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>
251
252 <p><code class="func">IntersectBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>
253
254
255 <div class="example"><pre>
256 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
257 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
258 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IntersectBlist( blist1, blist2 );</span>
259 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
260 [ true, false, false, false ]
261 </pre></div>
262
263 <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>
264
265 <p><a id="X7AA138407D5A3BAC" name="X7AA138407D5A3BAC"></a></p>
266
267 <h5>22.4-4 SubtractBlist</h5>
268
269 <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>
270 <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>
271
272 <p><code class="func">SubtractBlist</code> returns nothing, it is only called to change <var class="Arg">blist1</var>.</p>
273
274
275 <div class="example"><pre>
276 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, false, false ];;</span>
277 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
278 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SubtractBlist( blist1, blist2 );</span>
279 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
280 [ false, true, false, false ]
281 </pre></div>
282
283 <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>
284
285 <p><a id="X830645EC846B2E3C" name="X830645EC846B2E3C"></a></p>
286
287 <h5>22.4-5 MeetBlist</h5>
288
289 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MeetBlist</code>( <var class="Arg">blist1</var>, <var class="Arg">blist2</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
290 <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)) &lt;&gt; 0</code>. An error is thrown if the lists do not have the same length.</p>
291
292
293 <div class="example"><pre>
294 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
295 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
296 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MeetBlist( blist1, blist2 );</span>
297 true
298 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FlipBlist( blist1 );</span>
299 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MeetBlist( blist1, blist2 );</span>
300 false
301 </pre></div>
302
303 <p><a id="X7F14FF35786DAEF3" name="X7F14FF35786DAEF3"></a></p>
304
305 <h5>22.4-6 FlipBlist</h5>
306
307 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FlipBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
308 <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>
309
310 <p><code class="func">FlipBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>
311
312
313 <div class="example"><pre>
314 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
315 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
316 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SubtractBlist( blist1, blist2 );</span>
317 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
318 [ false, true, false, true ]
319 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FlipBlist( blist2 );</span>
320 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2;</span>
321 [ false, true, false, true ]
322 </pre></div>
323
324 <p><a id="X7E9F6C197A79098F" name="X7E9F6C197A79098F"></a></p>
325
326 <h5>22.4-7 SetAllBlist</h5>
327
328 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SetAllBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
329 <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>
330
331 <p><code class="func">SetAllBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>
332
333
334 <div class="example"><pre>
335 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
336 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
337 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SetAllBlist( blist1 );</span>
338 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
339 [ true, true, true, true ]
340 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">SetAllBlist(blist2);</span>
341 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2;</span>
342 [ true, true, true, true ]
343 </pre></div>
344
345 <p><a id="X87ED45A88688AE8E" name="X87ED45A88688AE8E"></a></p>
346
347 <h5>22.4-8 ClearAllBlist</h5>
348
349 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ClearAllBlist</code>( <var class="Arg">blist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
350 <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>
351
352 <p><code class="func">ClearAllBlist</code> returns nothing, it is only called to change <var class="Arg">blist</var> in-place.</p>
353
354
355 <div class="example"><pre>
356 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1 := [ true, true, true, true ];;</span>
357 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2 := [ true, false, true, false ];;</span>
358 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ClearAllBlist( blist1 );</span>
359 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist1;</span>
360 [ false, false, false, false ]
361 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ClearAllBlist(blist2);</span>
362 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">blist2;</span>
363 [ false, false, false, false ]
364 </pre></div>
365
366 <p><a id="X7C71B225841DFC0F" name="X7C71B225841DFC0F"></a></p>
367
368 <h4>22.5 <span class="Heading">More about Boolean Lists</span></h4>
369
370 <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>
371
372 <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>
373
374 <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>
375
376 <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>
377
378 <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>
379
380 <p><a id="X8453ADDA810B4C03" name="X8453ADDA810B4C03"></a></p>
381
382 <h5>22.5-1 IsBlistRep</h5>
383
384 <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>
385 <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>
386 <p>Returns: <code class="keyw">true</code> or <code class="keyw">false</code></p>
387
388 <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>
389
390 <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>
391
392
393 <div class="example"><pre>
394 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l := [true, false, true];</span>
395 [ true, false, true ]
396 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlistRep(l);</span>
397 true
398 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l := [true, false, 1];</span>
399 [ true, false, 1 ]
400 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">l[3] := false;</span>
401 false
402 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsBlistRep(l);</span>
403 false
404 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ConvertToBlistRep(l);</span>
405 true
406 </pre></div>
407
408
409 <div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap21.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap23.html">[Next Chapter]</a>&nbsp; </div>
410
411
412 <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>
413
414 <hr />
415 <p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
416 </body>
417 </html>