A simple timer in Clojure

less than 1 minute read

Notes

1
2
3
4
5
6
7
8
9
10
11
12
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)

Clojure Tamilnadu groups

Updated: