summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/MultiCpu.hs
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2010-12-11 23:52:50 -0500
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-12 14:15:50 +0100
commitfb2a29ba87339bd155aa3bbe4a6754da738ff58e (patch)
treea3833a64ed79de062872f7c6b6c345feaba93fad /Plugins/Monitors/MultiCpu.hs
parent7396a13c49c23adc414543ec4696ac3e452e4bfe (diff)
downloadxmobar-fb2a29ba87339bd155aa3bbe4a6754da738ff58e.tar.gz
xmobar-fb2a29ba87339bd155aa3bbe4a6754da738ff58e.tar.bz2
Clean up splitEvery implementation
Diffstat (limited to 'Plugins/Monitors/MultiCpu.hs')
-rw-r--r--Plugins/Monitors/MultiCpu.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs
index 492ad96..fff72cc 100644
--- a/Plugins/Monitors/MultiCpu.hs
+++ b/Plugins/Monitors/MultiCpu.hs
@@ -16,7 +16,7 @@ module Plugins.Monitors.MultiCpu(multiCpuConfig, runMultiCpu) where
import Plugins.Monitors.Common
import qualified Data.ByteString.Lazy.Char8 as B
-import Data.List (isPrefixOf,intersperse,transpose)
+import Data.List (isPrefixOf,intersperse,transpose,unfoldr)
multiCpuConfig :: IO MConfig
multiCpuConfig =
@@ -61,9 +61,10 @@ formatCpu xs
ps <- showPercentsWithColors (t:xs)
return (b:ps)
-splitEvery :: Int -> [a] -> [[a]]
-splitEvery _ [] = []
-splitEvery n l = (take n l) : splitEvery n (drop n l)
+splitEvery :: (Eq a) => Int -> [a] -> [[a]]
+splitEvery n = unfoldr (\x -> if x == []
+ then Nothing
+ else Just $ splitAt n x)
groupData :: [String] -> [[String]]
groupData = transpose . tail . splitEvery 6