You're viewing version 1.2.0 of while. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

while

clojure.core

  • (while test & body)
Repeatedly executes body while test expression is true. Presumes
some side-effect will cause test to become false/nil. Returns nil

1 Example top

  • user=> (def a (atom 10))                                
    #'user/a
    
    user=> (while (pos? @a) (do (println @a) (swap! a dec)))
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    nil
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/loop

    Evaluates the exprs in a lexical context in which the symbols in th

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:5072 top

(defmacro while
  "Repeatedly executes body while test expression is true. Presumes
  some side-effect will cause test to become false/nil. Returns nil"
  {:added "1.0"}
  [test & body]
  `(loop []
     (when ~test
       ~@body
       (recur))))
Vars in clojure.core/while: defmacro test apply concat list loop seq vector when

Comments top

No comments for while. Log in to add a comment.