Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Sparkline-in-unicode/Clojure/sparkline-in-unicode.clj
Normal file
15
Task/Sparkline-in-unicode/Clojure/sparkline-in-unicode.clj
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(defn sparkline [nums]
|
||||
(let [sparks "▁▂▃▄▅▆▇█"
|
||||
high (apply max nums)
|
||||
low (apply min nums)
|
||||
spread (- high low)
|
||||
quantize #(Math/round (* 7.0 (/ (- % low) spread)))]
|
||||
(apply str (map #(nth sparks (quantize %)) nums))))
|
||||
|
||||
(defn spark [line]
|
||||
(if line
|
||||
(let [nums (read-string (str "[" line "]"))]
|
||||
(println (sparkline nums))
|
||||
(recur (read-line)))))
|
||||
|
||||
(spark (read-line))
|
||||
Loading…
Add table
Add a link
Reference in a new issue