Do-while loop in Clojure?

前端 未结 1 620
挽巷
挽巷 2020-12-20 17:50

So I want to first execute a bunch of code, and then ask the user if he wants to do that again. I thought the most convenient way to do this would be a do-while loo

相关标签:
1条回答
  • 2020-12-20 18:41

    Here is a slightly changed version of Clojure's while macro, where the test is done after evaluating the body:

    (defmacro do-while
      [test & body]
      `(loop []
         ~@body
         (when ~test
           (recur))))
    
    0 讨论(0)
提交回复
热议问题