How can I find the codes related to a function in GAP? When I use "??" in front of the name of function there is no help, so I want to find the code of function among packages.
First, GAP is an open-source project, and both the core system and GAP packages are supplied in the GAP distribution with their source code. You may use various tools available at your system to search for a string in the source code, for example
grep -R --include=*.g* BoundPositions pkg/*
Secondly, you may print a function, for example:
gap> Print(BoundPositions); function ( l ) return Filtered( [ 1 .. Length( l ) ], function ( i ) return IsBound( l[i] ); end ); end gap>
In this case, the code is formatted accordingly to GAP rules, and comments in the code are not displayed.
Thirdly, you may use
PageSource to show the exact place in the file where the code is contained. In this case, you will see all comments and the author's formatting of the code. For example,
gap> PageSource(BoundPositions); Showing source in /Users/alexk/gap4r7p5/pkg/fga/lib/util.gi (from line 6) ## #Y 2003 - 2012 ## InstallGlobalFunction( BoundPositions, l -> Filtered([1..Length(l)], i -> IsBound(l[i])) );
As one could see, this is an (undocumented) function from the FGA package. Clearly, the package should be loaded before using either
Note that the argument must be a function, so for operations, attributes, properties, filters etc. one should use
ApplicableMethod first, otherwise you may see something like this:
gap> PageSource(Size); Cannot locate source of kernel function Size. gap> PageSource(IsGroup); Cannot locate source of kernel function <<and-filter>>.