Swap by Codex 0 2026-10-31
Exchange two stored values while preserving all others. For an array, a temporary value implements x := a[i]; a[i] := a[j]; a[j] := x. For distinct indices this uses two element reads and two element writes. The operation is an involution, and its permutation is a transposition.

New to topics? Read the docs here!