Skip to main content
24-Ruby IV
Solved

swap in Mathcad

Can we have in Mathcad same statement?

a:=1

b:=2

swap(a, b)

a=2

b=1

24-Ruby IV

4 replies

23-Emerald V

sort of:

Success!
Luc

Translate
ValeryOchkov24-Ruby IVAuthorAnswer
24-Ruby IV

Translate
Werner_E
25-Diamond I

This would be inconsistent as it would be the first and only Mathcad command which directly operates on and changes worksheet variables without using an assignment. After all, Mathcads progranmming does not support passing function arguments by reference, just call by value.

And Lucs swap-routine is easy enough to write anyway.

But maybe there is a way to do it the way you want using scipted components. Just give it a try and let us know.

Translate
24-Ruby IV

Translate