From fb2a29ba87339bd155aa3bbe4a6754da738ff58e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 11 Dec 2010 23:52:50 -0500 Subject: Clean up splitEvery implementation --- Plugins/Monitors/MultiCpu.hs | 9 +++++---- 1 file 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 -- cgit v1.2.3