Swap Without Temporary Variable.
; Short one, inspired by blog post posted by Cormullion on Newlisp forum:
; Swap values of two variables without using temporary variable.
(set 'a 1 'b 2)
(println a "," b); 1, 2
(set 'a (+ a b))
(set 'b (- a b))
(set 'a (- a b))
(println a "," b); 2, 1
(exit)
Subscribe to:
Posts (Atom)