4.6 Elements

Elements( D )

Elements returns the set of elements of the domain D. The set is returned as a new proper set, i.e., as a new sorted list without holes and duplicates (see Sets). D may also be a list, in which case the set of elements of this list is returned. An error is signalled if D is an infinite domain.

    gap> Elements( GaussianIntegers );
    Error, the ring <R> must be finite to compute its elements
    gap> D12 := Group( (2,6)(3,5), (1,2)(3,6)(4,5) );;
    gap> Elements( D12 );
    [ (), (2,6)(3,5), (1,2)(3,6)(4,5), (1,2,3,4,5,6), (1,3)(4,6),
      (1,3,5)(2,4,6), (1,4)(2,3)(5,6), (1,4)(2,5)(3,6), (1,5)(2,4),
      (1,5,3)(2,6,4), (1,6,5,4,3,2), (1,6)(2,5)(3,4) ] 

Elements remembers the set of elements in the component D.elements and will return a shallow copy (see ShallowCopy) next time it is called to compute the elements of D. If you want to avoid this, for example for a large domain, for which you know that you will not need the list of elements in the future, either unbind (see Unbind) D.elements or call D.operation.Elements(D) directly.

Since there is no general method to compute the elements of a domain the default function DomainOps.Elements just signals an error. This default function is overlaid for each special finite domain. In fact, implementors of domains, must implement this function for new domains, since it is, together with IsFinite (see IsFinite) the most basic function for domains, used by most of the default functions in the domain package.

In general functions that return a set of elements are free, in fact encouraged, to return a domain instead of the proper set of elements. For one thing this allows to keep the structure, for another the representation by a domain record is usually more space efficient. Elements must not do this, its only purpose is to create the proper set of elements.

Previous Up Top Next
Index

GAP 3.4.4
April 1997