/ Published in: Clojure
first try, use with care
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(defn progress "prints a progressbar to shell, use repeatetly to 'update' the progressbar" [posV maxV & text] (let [ barmax 80 multiplier (/ barmax maxV) pos_ (min (round (* posV multiplier)) barmax) start \[ end \] left (apply str (repeat pos_ \=)) right (apply str (repeat (- barmax pos_) \-)) style \> msg (first text)] (binding [*out* *err*] (print (str "\r" start left style right end) msg) (flush)) ) )