focus expression text field at startup -> version 1.2
[LeanCalc.git] / help / swap
1 NAME
2     swap - swap values of two variables
3
4 SYNOPSIS
5     swap(x,y)
6
7 TYPES
8     x, y        lvalues, any type
9
10     return      null value
11
12 DESCRIPTION
13    swap(x,y) assigns the value of x to a temporary location, temp say,
14    assigns the value of x to y, and then assigns the value at temp to y.
15
16    swap(x,y) should not be used if the current value of one of the
17    variables is a component of the value of the other; for example, after:
18
19          A = list(1,2,3); swap(A, A[[1]]);
20
21    A will have the value 2, but a three-member list remains in memory
22    with no method within calc of recalling the list or freeing the
23    memory used.
24
25 EXAMPLE
26    > x = 3/4; y = "abc"; print x, y, swap(x,y), x, y
27    .75 abc  abc .75
28
29    > A = list(1,2,3); mat B[3] = {4,5,6}; swap(A[[1]], B[1]); print A[[1]], B[1]
30    5 2
31
32 LIMITS
33     none
34
35 LINK LIBRARY
36     none
37
38 SEE ALSO
39     assign
40