[GAP Forum] Storing GAP codes

Alexander Konovalov alexander.konovalov at gmail.com
Mon Feb 9 23:42:51 GMT 2009


Hello Don,

On 4 Feb 2009, at 11:59, Don King wrote:

> Hello, I am a newbie of GAP and a lot of things are not still  
> familiar to me.
> Currently, I am testing some external GAP sources that are available  
> in this forum.
> The problem is I have to type every same codes for testing the same  
> program. (I still could not figure out how to copy/paste to GAP  
> console (gapw95.exe)).

See the GAP tutorial about this:

2.2 Loading Source Code from a File

The most convenient way of creating larger pieces of GAP code is to  
write them to some text file -- for this purpose you can simply use  
your favorite text editor. You can load such a file into GAP using the  
Read function:
gap> Read("../../GAPProgs/Example.g");
You can either give the full absolute path name of the source file or  
its relative path name from the GAP root directory (the directory  
containing bin/, doc/, lib/, etc.).

Copy/paste also should work - click on the icon in the left top corner  
of the window to see the menu, and then go to "Edit" to see all  
related menu items, or try or Ctrl+Ins/Shift+Ins in the Rxvt shell.  
Please let me know if none of this works.

Best wishes,
Alexander


> What I desire to do is to save a code like a batch file (or script  
> file) and execute it using that batch file.
> For instance, I'd like to make the below code as a batch file so  
> that I can execute the below routine using a batch file.
>
> Any help will be highly appreciated.
> Best regards,
> Don
>
>
>
>
>
> InvolutionFactors := function ( perm )
> local x, y, c, n, i;
> if not IsPerm(perm) then
>  Error("<perm> must be a permutation");
> fi;
> if OrderPerm(perm) <= 2 then
>  return [ perm, () ];
> fi;
>
>  x := ();
>  y := ();
>  for c in Cycles(perm, [1..LargestMovedPointPerm(perm)]) do
>    n := Length(c);
>    for i in [1..QuoInt(n-1, 2)] do
>      x := x * (c[i], c[n-i]);
>    od;
>    for i in [1..QuoInt(n, 2)] do
>      y := y * (c[i], c[n+1-i]);
>    od;
>  od;
>  return [x, y];
> end;



More information about the Forum mailing list