1.3.0 permalink 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:5569 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:
Used in 0 other vars

Comments top

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