# Definition:Replacement Operation

## Definition

The replacement operation on two variables $a$ and $b$ is denoted:

$a \gets b$

and is interpreted as:

the value of variable $a$ is to be replaced by the current value of variable $b$, while leaving the value of variable $b$ the same.

## Examples

### Exchange Operation as Replacement Operations

Let $x$ and $y$ be variables whose values are to be exchanged.

The exchange operation on $x$ and $y$ can be implemented using replacement operations.

Let $t$ be a third variable which has been established for this purpose.

Then the sequence of replacement operations:

$t \gets x$
$x \gets y$
$y \gets t$

### Rearrangement Operation as Replacement Operations

Let $\left({a, b, c, d}\right)$ be an ordered quadruple consisting of four variables whose values are to be rearranged into the order $\left({b, c, d, a}\right)$.

This can be implemented using replacement operations.

Let $t$ be a new variable which has been established for this purpose.

Then the sequence of replacement operations:

$t \gets a$
$a \gets b$
$b \gets c$
$c \gets d$
$d \gets t$