[GAP Forum] function search feature

Alexander Konovalov alexk at mcs.st-andrews.ac.uk
Thu Feb 23 20:11:20 GMT 2012


Dear Jakob, dear GAP Forum,

I've noticed that this question was not answered yet in the Forum:

On 9 Jan 2012, at 09:59, kroeker wrote:

> Hello,
> 
> sometimes I am looking for a function which is applicable to a specific object
> without knowing the name of the function. To find the desired function
> I have to read a lot of documentation, look for examples, ask an experienced GAP programmer (or the GAP-Forum) and so on.
> 
> Would it be possible to implement a search through all existing functions
> where one of the parameters is an object of a specified type?

So, the short answer is 'No' - GAP function may take any argument(s), one does not
specify to which arguments it applies when the function is created. GAP also
has a notion of 'operation' which is a bunch of functions, called 'methods' 
- these are installed with particular requirements on their arguments. Here 
you may call ApplicableMethod (see ?ApplicableMethod) to get the function 
which will be applied to arguments in a call to a specified operation - but
this is not what you want, since you need to know the name of the operation
in advance. For example,

gap> ApplicableMethod(Size,[Group((1,2))]);
function( G ) ... end

or (with more detailed output)

gap> ApplicableMethod(Size,[Group((1,2))],"all");
#I  Searching Method for Size with 1 arguments:
#I  Total: 57 entries
...
9: ``Size: for a permutation group that knows to be a direct product'', value: 34
#I   - 1st argument needs [ "Tester(DirectProductInfo)" ]
#I  Method 10: ``Size: for a permutation group'', value: 33
#I  Function Body:
function ( G )
   return SizeStabChain( StabChainMutable( G ) );
endfunction( G ) ... end
gap> 

A hint for an effective search in the GAP documentation is to invoke the help
from the command line rather then browsing PDF or HTML version. Type ?help in 
your GAP session to display further instructions. The query of the form ??word 
will show all help sections in all books whose index entries contain the 
substring word. For example,

gap> ??torsion                                                        
Help: several entries match this topic - type ?2 to get match [2]

[1] FR (not loaded): IsTorsionGroup
[2] FR (not loaded): IsTorsionFreeGroup
[3] HAP (not loaded): TorsionGeneratorsAbelianGroup
[4] polycyclic: TorsionByPolyEFSeries
[5] polycyclic: TorsionSubgroup
[6] polycyclic: NormalTorsionSubgroup
[7] polycyclic: IsTorsionFree
[8] RCWA (not loaded): An infinite subgroup of CT(GF(2)[x]) with many torsion elements
gap>

If you prefer HTML or PDF version, see ?SetHelpViewer for instructions how to change 
the default viewer.

Hope this helps,
Alexander


More information about the Forum mailing list