about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2023-02-27 13:09:17 -0500
committerelioat <elioat@tilde.institute>2023-02-27 13:09:17 -0500
commit42ee50b88f10b7578c9ea4271c13aaa77ed66e73 (patch)
tree2b7473eed6f06b4b2c7a38e25a2d224bb837ec5b
parenta36b86811b276916adbda6120c1cac8058ac4c17 (diff)
downloaddecember-2022-main.tar.gz
-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