Repeatedly executes body while test expression is true, evaluating the body with binding-form bound to the value of test.
I've found this particularly useful with core.async, where you want to loop until a channel is closed (and it returns nil).
In your project.clj add:
(while-let bindings & body)
Pop each item off the front of a vector and print it out.
(let [data (atom [1 2 3 4 5])]
(while-let [item (first @data)]
(println "item: " item)
(swap! data rest)))
Take from a channel until it gets closed (a closed channel will return nil
), or the channel returns false
(go (while-let [data (<! (channel))]
(println data)))
Copyright © 2014 Mark Mandel
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.