The infixed operators =>, :=, and =< can all store a value in a variable, but their arguments are in different order. (See Section 3.3.2 and Section 3.3.3.) Also, := and =< have different effects when the first argument is an element of a list stored in a variable, since =< modifies list elements by reference (see section 25.2.10).
=> is the infixed version of sto, it stores the value in the first argument in the variable in the second argument. Both
4=>a |
and
sto(4,a) |
store the value 4 in the variable a.
:= and =< both have a variable as the first argument and the value to store in the variable as the second argument. Both
a:=4 |
and
a=<4 |
store the value 4 in the variable a.
However, suppose you have entered:
A:=[0,1,2,3,4]:; B:=A |
and you want to change A[3], then the commandline
A[3]=<33 |
will change both A and B:
A,B |
|
Here, A pointed to the list [0,1,2,3,4] and after setting B to A, B also pointed to [0,1,2,3,4]. Changing an element of A by reference changes the list that A points to, which B also points to.
Note that multiple assigments can be made using sequences or lists. Both
[a,b,c]:=[1,2,3] |
and
(a,b,c):=(1,2,3) |
assign a the value 1, b the value 2, and c the value 3. If multiple assignments are made this way and variables are on the right hand side, they will be replaced by their values before the assignment. If a contains 5 and you enter:
(a,b):=(2,a) |
then b will get the previous value of a, 5, and not the new value of a, 2.