; 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)
(set 'a 1 'b 2)
ReplyDelete(println a "," b); 1, 2
(map set '(a b) (list b a))
(println a "," b); 2, 1
Good idea!
ReplyDeleteGreat idea - works with everything, not just numbers.
ReplyDelete