Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding multiple related variables in Clojure without nested let

I want to use the value of a variable to compute the value of another variable in the same let statement. Is there a way to do this in Clojure without using nested lets?

Nested let solution:

(let [x 3] 
  (let [y (+ 1 x)] 
    y)) = 4

Desired solution:

(let [x 3 
      y (+ 1 x)] 
   y) = 4
like image 669
Kai Avatar asked Jun 19 '09 15:06

Kai


1 Answers

Never mind, the desired solution works fine. I wonder why I was having trouble with it before?

like image 152
Kai Avatar answered Sep 18 '22 14:09

Kai