For some lists the kernel knows that they are in fact ranges. Those lists are represented internally in a compact way instead of the ordinary way. This is important since this representation needs only 12 bytes for the entire list while the ordinary representation needs 4 length bytes.
Note that a list that is represented in the ordinary way might still be a range. It is just that GAP does not know this. This section tells you under which circumstances a range is represented in the compact way, so you can write your program in such a way that you make best use of this compact representation for ranges.
Lists created by the syntactic construct
[ first, second .. last
] are of course known to be ranges and are represented in the compact
If you call
IsRange for a list represented the ordinary way that is
indeed a range,
IsRange will note this, change the representation from
the ordinary to the compact representation, and then return
If you change a range that is represented in the compact way, by
Append, the range will be converted to the
ordinary representation, even if the change is such that the resulting
list is still a proper range.
Suppose you have built a proper range in such a way that it is
represented in the ordinary way and that you now want to convert it to
the compact representation to save space. Then you should call
with that list as an argument. If it is indeed a proper range,
will convert it to the compact representation. You can think of the call
IsRange as a hint to GAP that this list is a proper range.
Previous Up Top