Sparkline in unicode: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Updated minimal Haskell version for stronger parallel to second Python version) |
|||
Line 835: | Line 835: | ||
Or, stripping back a little: |
Or, stripping back a little: |
||
{{Trans|Python}} |
|||
<lang haskell>import Data.List.Split (splitOneOf) |
<lang haskell>import Data.List.Split (splitOneOf) |
||
import Data.List (findIndex) |
import Data.List (findIndex) |
||
import Data.Maybe (maybe) |
|||
import Control.Arrow ((&&&)) |
import Control.Arrow ((&&&)) |
||
Line 844: | Line 846: | ||
w = (mx - mn) / 8 |
w = (mx - mn) / 8 |
||
lbounds = ((mn +) . (w *)) <$> [1 .. 7] |
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] |
parseFloats :: String -> [Float] |