Quantcast
Viewing latest article 6
Browse Latest Browse All 9

Answer by Jens Krüger for R: Swap two variables without using a third

Start

A = 9B = 5A = A + B   

Then

A is 14B is 5B = A - B

Then

A is 14B is 9A = A - B 

Result:

A(5) is now B

B(9) is now A

Not really simpler then just using a third variable but i works!


Viewing latest article 6
Browse Latest Browse All 9

Trending Articles