Jump to content

Sparkline in unicode: Difference between revisions

→‎{{header|Haskell}}: Updated minimal Haskell version for stronger parallel to second Python version
(→‎{{header|Haskell}}: Updated minimal Haskell version for stronger parallel to second Python version)
Line 835:
 
Or, stripping back a little:
{{Trans|Python}}
<lang haskell>import Data.List.Split (splitOneOf)
import Data.List (findIndex)
import Data.Maybe (maybe)
import Control.Arrow ((&&&))
 
Line 844 ⟶ 846:
w = (mx - mn) / 8
lbounds = ((mn +) . (w *)) <$> [1 .. 7]
in fmap (maybe '█' ("▁▂▃▄▅▆▇" !!) . flip findIndex lbounds . flip (>)) xs
in fmap
(\x ->
case findIndex (> x) lbounds of
Nothing -> '█'
Just i -> "▁▂▃▄▅▆▇" !! i)
xs
 
parseFloats :: String -> [Float]
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.