Clojure: equivalent of "do" from Common Lisp
clojure, common-lisp, lisp
Solution
Clojure avoids these kind of sequential binding forms, but the same functionality can be expressed with `while` or `loop` - the first example from the CLHS in each style:
;; common lisp version
(do ((temp-one 1 (1+ temp-one))
(temp-two 0 (1- temp-two)))
((> (- temp-one temp-two) 5) temp-one)) => 4
;; clojure, while
(let [temp-one (atom 1)
temp-two (atom 0)]
(while (> (- @temp-one @temp-two) 5)
(swap! temp-one inc)
(swap! temp-two dec))
@temp-one)
;; clojure, loop
(loop [temp-one 1 temp-two 0]
(if (> (- temp-one temp-two) 5)
temp-one
(recur (inc temp-one) (dec temp-two))))
Problem
Newbie Lisp question, sorry for the ignorance. What is the equivalent of Common Lisp's `do` in Clojure?