Skip to content

Instantly share code, notes, and snippets.

@jclaggett
Last active December 30, 2015 09:09
Show Gist options
  • Select an option

  • Save jclaggett/7807482 to your computer and use it in GitHub Desktop.

Select an option

Save jclaggett/7807482 to your computer and use it in GitHub Desktop.

Revisions

  1. jclaggett renamed this gist Dec 5, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. jclaggett renamed this gist Dec 5, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. jclaggett created this gist Dec 5, 2013.
    7 changes: 7 additions & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    (defn sparkline [values]
    (let [low (apply min values)
    high (apply max values)
    bars "▁▂▃▄▅▆▇█"
    step (/ (- high low) (dec (count bars)))
    scale #(nth bars (int (/ (- % low) step)))]
    (apply str (map scale values))))