up previous next
 3.4.2 Assignment
An assignment command has the form
```  L := E
```
where L is a variable and E is an expression. The assignment command binds the result of the evaluation of the expression E to L in the working memory (see the chapter entitled Memory Management). If E is dependent upon a ring, then L is labeled with that ring. The label is listed when L is evaluated in another ring. Then command RingEnv(L) will return the label for L.

 Example
 ``` Use R ::= QQ[t,x,y,z]; I := Ideal(x,y); M := 5; N := 8; T := M+N; T; 13 ------------------------------- T := T+1; -- note that T occurs on the right, also T; 14 ------------------------------- L := [1,2,3]; L[2] := L[3]; L; [1, 3, 3] ------------------------------- P := Record[F = xz]; P.Degree := Deg(P.F); P; Record[Degree = 2, F = xz] ------------------------------- Use S ::= QQ[a,b]; I; -- I is labeled by R since it depends on R R :: Ideal(x, y) ------------------------------- T; -- T is not labeled by R 14 ------------------------------- J := R:: Ideal(x^2-y); -- J contains an object dependent on R J; -- since the ring S is active, J is labeled by R R :: Ideal(x^2 - y) ------------------------------- Use R; J; Ideal(x^2 - y) ------------------------------- ```
For information about interacting with rings outside of the current ring, see Accessing Other Rings in the chapter entitled Rings.

To assign values to global variables, see Introduction to Memory or Global Memory.