Q: how can I
let-bind multiple variables conditional on x?
Assume that I have three variables,
c, that I want
let-bind conditional on some other
x. How do I do that
concisely and idiomatically?
Here's an example that works, but is repetitive and error-prone:
(let ((a (if t 1 4)) (b (if t 2 5)) (c (if t 3 6))) (list a b c)) ; => (1 2 3)
Here's another example that works, but the use of
both repetitive and inelegant:
(let (a b c) (if t (setq a 1 b 2 c 3) (setq a 4 b 5 c 6)) (list a b c)) ; => (1 2 3)
Here's an example that doesn't work, because the variables fall
outside the scope of the
(if t (let ((a 1) (b 2) (c 3))) (let ((a 4) (b 5) (c 6))) (list a b c)) ; => nil
What is the idiomatic way to do this?