CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Path: gap4r8 / doc / ref / blist.xml
Views: 418346
1
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
2
<!-- %% -->
3
<!-- %A blist.msk GAP documentation Martin Schönert -->
4
<!-- %% -->
5
<!-- %A @(#)<M>Id: blist.msk,v 1.9 2002/04/15 10:02:27 sal Exp </M> -->
6
<!-- %% -->
7
<!-- %Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland -->
8
<!-- %Y Copyright (C) 2002 The GAP Group -->
9
<!-- %% -->
10
<Chapter Label="Boolean Lists">
11
<Heading>Boolean Lists</Heading>
12
13
This chapter describes boolean lists.
14
A <E>boolean list</E> is a list that has no holes and contains only
15
the boolean values <K>true</K> and <K>false</K>
16
(see Chapter&nbsp;<Ref Chap="Booleans"/>).
17
In function names we call boolean lists <E>blists</E> for brevity.
18
19
20
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
21
<Section Label="sect:IsBlist">
22
<Heading>IsBlist (Filter)</Heading>
23
24
<#Include Label="IsBlist">
25
26
</Section>
27
28
29
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
30
<Section Label="Boolean Lists Representing Subsets">
31
<Heading>Boolean Lists Representing Subsets</Heading>
32
33
<#Include Label="BlistList">
34
<#Include Label="ListBlist">
35
<#Include Label="SizeBlist">
36
<#Include Label="IsSubsetBlist">
37
38
</Section>
39
40
41
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
42
<Section Label="Set Operations via Boolean Lists">
43
<Heading>Set Operations via Boolean Lists</Heading>
44
45
<#Include Label="UnionBlist">
46
<#Include Label="IntersectionBlist">
47
<#Include Label="DifferenceBlist">
48
49
</Section>
50
51
52
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
53
<Section Label="Function that Modify Boolean Lists">
54
<Heading>Function that Modify Boolean Lists</Heading>
55
56
<#Include Label="UniteBlist">
57
<#Include Label="UniteBlistList">
58
<#Include Label="IntersectBlist">
59
<#Include Label="SubtractBlist">
60
61
</Section>
62
63
64
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
65
<Section Label="More about Boolean Lists">
66
<Heading>More about Boolean Lists</Heading>
67
68
We defined a boolean list as a list that has no holes and contains only
69
<K>true</K> and <K>false</K>.
70
There is a special internal representation for boolean lists that needs
71
only 1 bit for each entry.
72
This bit is set if the entry is <K>true</K> and reset if the entry is
73
<K>false</K>.
74
This representation is of course much more compact than the ordinary
75
representation of lists, which needs 32 or 64 bits per entry.
76
<P/>
77
<!-- %T Add a note about internal representation of plain lists (preferably in -->
78
<!-- %T the chapter <Q>Lists</Q>), -->
79
<!-- %T in order to allow a user to estimate the space needed for -->
80
<!-- %T computations with lists; -->
81
<!-- %T then add cross-references from and to the other available list -->
82
<!-- %T representations! -->
83
<P/>
84
Not every boolean list is represented in this compact representation. It
85
would be too much work to test every time a list is changed, whether this
86
list has become a boolean list. This section tells you under which
87
circumstances a boolean list is represented in the compact
88
representation, so you can write your functions in such a way that you make
89
best use of the compact representation.
90
<P/>
91
If a dense list containing only <K>true</K> and <K>false</K> is read, it
92
is stored in the compact representation. Furthermore,
93
the results of <Ref Func="BlistList"/>,
94
<Ref Func="UnionBlist" Label="for a list"/>,
95
<Ref Func="IntersectionBlist" Label="for a list"/>
96
and <Ref Func="DifferenceBlist"/> are known
97
to be boolean lists by construction, and thus
98
are represented in the compact representation upon creation.
99
<P/>
100
If an argument of <Ref Func="IsSubsetBlist"/>,
101
<Ref Func="ListBlist"/>, <Ref Func="UnionBlist" Label="for a list"/>,
102
<Ref Func="IntersectionBlist" Label="for a list"/>,
103
<Ref Func="DifferenceBlist"/>,
104
<Ref Func="UniteBlist"/>, <Ref Func="IntersectBlist"/> and
105
<Ref Func="SubtractBlist"/> is a list represented in the ordinary
106
representation, it is
107
tested to see if it is in fact a boolean list.
108
If it is not, an error is signalled. If it is, the
109
representation of the list is changed to the compact representation.
110
<P/>
111
If you change a boolean list that is represented in the compact
112
representation by assignment (see <Ref Sect="List Assignment"/>) or
113
<Ref Func="Add"/>
114
in such a way that the list remains a boolean list it will remain
115
represented in the compact representation. Note that changing a list
116
that is not represented in the compact representation, whether it is a
117
boolean list or not, in such a way that the resulting list becomes a
118
boolean list, will never change the representation of the list.
119
120
<#Include Label="IsBlistRep">
121
122
</Section>
123
</Chapter>
124
125
126
127