The next step is to add own operations. As an example we take the Sylow normalizer in a group of a given prime. This operation gets two arguments, the first has to be a group, the second a prime number.
There is a function IsPrimeInt, but no property for being prime (which
would be pointless as integers cannot store property values anyhow). So the
second argument gets specified only as positive integer:
SylowNormalizer:=NewOperation("SylowNormalizer",[IsGroup,IsPosInt]);
(Note that we are using NewOperation instead of DeclareOperation as used
in the library. The only difference is that DeclareOperation saves typing,
but protects the variables against overwriting. When testing code (when one
probably wants to change things) this might be restricting. If this does not
bother you, you can use
DeclareOperation("SylowNormalizer",[IsGroup,IsPosInt]);
as well.)
The filters IsGroup and IsPosInt given are only used to test that
InstallMethod installes methods with suitable arguments and will be
completely ignored when using InstallOtherMethod. Technically one could
therefore simply use IsObject for all arguments in the declaration. The
main point of using more specific filters here is to help documenting with
which arguments the function is to be used (so for example a call
SylowNormalizer(5,G) would be invalid).
Of course initially there are no useful methods for newly declared operations, but you will have to write and install them yourself.
If the operation only takes one argument and has reproducible results without side effects, it might be worth declaring it as an attribute instead.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual