about summary refs log tree commit diff stats
path: root/rnd/clj/timer.clj
blob: 47fef780abc59c72e86c9bded4154c1ca4ebc6a1 (plain) (blame)
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)