Skip to content

Instantly share code, notes, and snippets.

@aristidb
Created November 15, 2011 19:41
Show Gist options
  • Select an option

  • Save aristidb/1368094 to your computer and use it in GitHub Desktop.

Select an option

Save aristidb/1368094 to your computer and use it in GitHub Desktop.
Slightly changed version
-- Generate a sparkline, Haskell version of <https://github.com/holman/spark/>
-- Usage: after compile, try '$ spark -10 0 15.24 42'
-- Author: Chao Xu, <http://chaoxuprime.com>
import System (getArgs)
main :: IO ()
main = do input <- getArgs
putStrLn $ spark (map read input :: [Double])
spark :: RealFrac b => [b] -> String
spark list = map ("▁▂▃▄▅▆▇" !!) scaled
where transl = subtract (minimum list)) `map` list
scaled = (round . (* 6) . (/ maximum transl)) `map` transl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment