[GAP Forum] Indeterminates

Alexander Hulpke hulpke at me.com
Fri Jul 31 09:29:30 BST 2009


Dear Matthew Fayers, Dear Forum,

> I have a custom package containing lots of functions that I use  
> frequently, that I usually read into GAP at the start of every  
> session.  Since I frequently use polynomials in one variable, one of  
> the first lines of this package is
>
> q:=Indeterminate(Rationals,"q");
>
> The trouble is, if I modify the package and then re-read it into the  
> session, GAP reads the line above again and assigns two  
> indeterminates, both called q.  This causes problems for functions  
> that refer to q.

What you can do is to use instead the internal number of the  
indeterminate (it just will be your taks to make sure that different  
variables have diferent numbers). This will ensure that you get every  
time the same object:

q:=Indeterminate(Rationals,1);

Then use `SetName' to assign the name. (This is safe for reloading, as  
long as the name being reassigned is the same.)
SetName(q,"q");

The next major release of GAP will contain an option to specify in a  
call like your original one whether you want the same variable if  
possible.

I hope this helps,

     Alexander Hulpke


-- Colorado State University, Department of Mathematics,
Weber Building, 1874 Campus Delivery, Fort Collins, CO 80523-1874, USA
email: hulpke at math.colostate.edu, Phone: ++1-970-4914288
http://www.math.colostate.edu/~hulpke




More information about the Forum mailing list