diff --git a/lib/domain.gd b/lib/domain.gd index 76c83c75b4..720a2a7721 100644 --- a/lib/domain.gd +++ b/lib/domain.gd @@ -136,6 +136,7 @@ InstallTrueMethod( IsDuplicateFree, IsDomain ); ## <#GAPDoc Label="GeneratorsOfDomain"> ## ## +## ## ## ## For a domain D, returns a list @@ -158,6 +159,9 @@ InstallTrueMethod( IsDuplicateFree, IsDomain ); ## D, D.i returns the i-th generator if ## i is a positive integer, and if name is the name of a ## generator of D then D.name returns this generator. +##

+## is a synonym for +## . ## ## ## <#/GAPDoc> diff --git a/lib/set.gd b/lib/set.gd index bf12a9adb9..8739383cf9 100644 --- a/lib/set.gd +++ b/lib/set.gd @@ -242,3 +242,9 @@ DeclareOperation( "IntersectSet", [ IsList and IsMutable, IsList ] ); ## <#/GAPDoc> ## DeclareOperation( "SubtractSet", [ IsList and IsMutable, IsList ] ); + +############################################################################# +## +# MOVE THIS TO domain.gd +DeclareSynonym("IsSetAsDomain", IsDomain); +DeclareSynonym("SetAsDomain", Domain); diff --git a/lib/set.gi b/lib/set.gi index ead4731ac9..e22f9c0076 100644 --- a/lib/set.gi +++ b/lib/set.gi @@ -222,3 +222,50 @@ InstallMethod( SubtractSet, RemoveSet( set, obj ); od; end ); + + +############################################################################# +## +InstallMethod(SetAsDomain, +"for a set & collection", +[IsSet and IsCollection], +function(set) + local copy, type, domain; + copy := Immutable(set); + type := NewType(FamilyObj(copy), + IsSetAsDomain and IsAttributeStoringRep); + return ObjectifyWithAttributes(rec(), type, + GeneratorsOfDomain, copy, + AsList, copy, + AsSet, copy); +end); + +# Provide family of objects `fam`. Then the resulting domain lives in the same +# family as a domain created from a non-empty set of objects of `fam`. +InstallOtherMethod(SetAsDomain, +"for a family and an empty list", +[IsFamily, IsEmpty and IsList], +function(family, set) + local copy, type; + copy := Immutable([]); + type := NewType(CollectionsFamily(family), + IsSetAsDomain and IsAttributeStoringRep); + return ObjectifyWithAttributes(rec(), type, + GeneratorsOfDomain, copy, + AsList, copy, + AsSet, copy); +end); + +InstallMethod(\in, +"for an IsSetAsDomain", +[IsObject, IsSetAsDomain], +function(elm, set) + return elm in AsList(set); +end); + +InstallMethod(PrintObj, +"for an IsSetAsDomain", +[IsSetAsDomain], +function( setAsDomain ) + Print("SetAsDomain(", AsList(setAsDomain), ")"); +end);