about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--rnd/clj/timer.clj13
1 files changed, 13 insertions, 0 deletions
diff --git a/rnd/clj/timer.clj b/rnd/clj/timer.clj
new file mode 100644
index 0000000..47fef78
--- /dev/null
+++ b/rnd/clj/timer.clj
@@ -0,0 +1,13 @@
+;; timer.clj
+
+(defn print-without-newline [string]
+  (print string)
+  (flush))
+
+(defn timer-for [minutes]
+  (let [seconds (* minutes 60)]
+    (doseq [n (reverse (range seconds))]
+      (Thread/sleep 1000)
+      (print-without-newline (str "\r" (quot n 60) " m " (mod n 60) " s ")))))
+
+(timer-for 1.1)
\ No newline at end of file