Reputation: 656
I want to call a function every second.
I have the following code:
(defn dostuff []
(do
(print "I'm doing stuff")
...))
(while true
(Thread/sleep 1000)
(dostuff))
I would expect this to print "I'm doing stuff" every second but it does not.
How do I achieve this?
Upvotes: 1
Views: 2001
Reputation: 13059
You're not flushing stdout. You can either use println, which is print
plus newline
(forces auto-flush), or explicitly call flush like this:
(defn dostuff []
(do
...
(print "I'm doing stuff")
(flush)))
Upvotes: 4