From 42ee50b88f10b7578c9ea4271c13aaa77ed66e73 Mon Sep 17 00:00:00 2001 From: elioat Date: Mon, 27 Feb 2023 13:09:17 -0500 Subject: * --- rnd/clj/timer.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rnd/clj/timer.clj (limited to 'rnd/clj/timer.clj') 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 -- cgit 1.4.1-2-gfad0