The error occurs, because in this snippet:
(let [vect '(1 2 3)]
{:a a :b b :c c})
You're binding vect
to '(1 2 3)
. The vect
earlier defined as '[a b c]
earlier will be shadowed by the local let binding. a
,b
and c
will be left unbound.
The only way I think you can do what you ask is by using (abusing?) eval/macros, and building up the exact form that you need.
(eval (list 'let [vect ''(1 2 3)] '{:a a :b b :c c}))
;; => {:a 1 :b 2 :c 3}
However, I really urge you to put in some hammock time here and think about why you need to destructure using a var, and possible alternative designs. The solution above is already pretty hacky and using it could get very ugly...