I have the following simple program:
(def time-format (new java.text.SimpleDateFormat "hh:mm:ss"))
(defn now []
(new java.util.GregorianCalendar))
(defn give-message [message]
(printf "%s: %s\n" (. time-format format (. (now) getTime)) message))
(give-message "Start")
(doseq [i (range 1 100000001)]
(let [val (Math/sqrt i)
diff (Math/abs (- (Math/pow val 2) (* val val)))]
(when-not (< diff 1.5E-8)
(println (format "Different for %d (%e)" i diff)))))
(give-message "Stop")
It does what it should, but I have a little problem with it: the output of
give-message is only showed after terminating the program. Why is that?
When changing give-message to:
(defn give-message [message]
(println (format "%s: %s" (. time-format format (. (now) getTime))
message)))
the output is shown immediately.
--
Cecil Westerhof
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.