Boolean Lists
This chapter describes boolean lists.
A boolean list is a list that has no holes and contains only
the boolean values true and false
(see Chapter ).
In function names we call boolean lists blists for brevity.
IsBlist (Filter)
<#Include Label="IsBlist">
Boolean Lists Representing Subsets
<#Include Label="BlistList">
<#Include Label="ListBlist">
<#Include Label="SizeBlist">
<#Include Label="IsSubsetBlist">
Set Operations via Boolean Lists
<#Include Label="UnionBlist">
<#Include Label="IntersectionBlist">
<#Include Label="DifferenceBlist">
Function that Modify Boolean Lists
<#Include Label="UniteBlist">
<#Include Label="UniteBlistList">
<#Include Label="IntersectBlist">
<#Include Label="SubtractBlist">
<#Include Label="FlipBlist">
<#Include Label="SetAllBlist">
<#Include Label="ClearAllBlist">
More about Boolean Lists
We defined a boolean list as a list that has no holes and contains only
true and false.
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 true and reset if the entry is
false.
This representation is of course much more compact than the ordinary
representation of lists, which needs 32 or 64 bits per entry.
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.
If a dense list containing only true and false is read, it
is stored in the compact representation. Furthermore,
the results of ,
,
and are known
to be boolean lists by construction, and thus
are represented in the compact representation upon creation.
If an argument of ,
, ,
,
,
, and
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.
If you change a boolean list that is represented in the compact
representation by assignment (see ) or
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.
<#Include Label="IsBlistRep">