CoCoA:NewId

From ApCoCoAWiki

NewId

create a new identifier

Description

This function returns a string of the form V#N where N is an

integer. Each time it is called, the integer N changes, producing a

new string. The purpose is to produce identifiers for variables or rings. (CoCoA does not check for the unlikely event that variables of the same form have been defined without the use of NewId.) The function NewId is often used with <ttref>Var</ttref>.

The most important use for this function is for creating temporary

rings within user-defined functions. For an example, see the section

of the tutorial entitled Rings Inside User-Defined Functions.

Example

  NewId();
V#0
-------------------------------
  NewId();
V#1
-------------------------------
  X := NewId();
  X;
V#2
-------------------------------
  Var(X) := 3;
  Var(NewId()) := 4;
  Describe Memory();
------------[Memory]-----------
It = V#2
V#2 = 3
V#3 = 4
X = V#2
-------------------------------
  Y := NewId();
  Var(Y) ::= Q[a,b];
  Use Var(Y);
  RingEnvs();
[<quotes>Q</quotes>, <quotes>Qt</quotes>, <quotes>R</quotes>, <quotes>V#6</quotes>, <quotes>Z</quotes>]
-------------------------------
  Y;
V#6
-------------------------------
  Var(Y);
Q[a,b]
-------------------------------

Syntax

NewId():STRING

Rings Inside User-Defined Functions

Var

   <type>function</type>
   <type>string</type>