I'd like to define two variables in let, one of which depends on the value of the other, like so:
(let ((a (func))
(b (if (eq a 1) 2 3)))
...)
Obviously this is not the right way to do this, emacs says a
is void.
What's the right way to do this?
Yes, you need to use let*
instead of let
.
Essentially, let*
is a shortcut for nested let
s:
(let ((a 1))
(let ((b (1+ a)))
(let ((c (* 2 b)))
...)))
is equivalent to
(let* ((a 1)
(b (1+ a))
(c (* 2 b)))
...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With