Skip to content

Instantly share code, notes, and snippets.

@NalaGinrut
Created April 17, 2014 10:08
Show Gist options
  • Save NalaGinrut/10970786 to your computer and use it in GitHub Desktop.
Save NalaGinrut/10970786 to your computer and use it in GitHub Desktop.
A macro for multi assign
(define-syntax sets!
(syntax-rules ()
((_ (var) (val))
(set! var val))
((_ (var vars* ...) (val vals* ...))
(let ((var0 val))
(sets! (vars* ...) (vals* ...))
(set! var var0)))))
@NalaGinrut
Copy link
Author

(define a)
(define b)
(define c)
(sets! (a b c) (1 2 3))
;; a=1, b=2, c=3

(sets! (a b c) (c b a))
;; a=3, b=2, c=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment