Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Erlang
fun1(A, B) ->
	do:something(),
	fun2(B, A).

fun2(A, B) ->
	now(A, is, B),
	and(B, is, A),
	keep:moving().

Single assignment precludes you from swapping values in Erlang within the body of a single function.
If you really want the names to change (which you usually don't)… well… you have to move to a different function
procedure swap(a, b: in out Integer)
is
    temp : Integer;
begin
    temp := a;
    a := b;
    b := temp;
end swap;

New implementation...
programming-idioms.org