Move splitBy to more general 'Util' module

This commit is contained in:
2014-10-07 19:22:37 +02:00
parent 73984b796d
commit 09ac8dd440
3 changed files with 16 additions and 11 deletions

13
Util.hs Normal file
View File

@@ -0,0 +1,13 @@
{-# OPTIONS_HADDOCK ignore-exports #-}
module Util where
-- |Split an array into subarrays depending on a given condition.
splitBy :: (a -> Bool) -- ^ condition
-> [a] -- ^ array to split
-> [[a]] -- ^ splitted array
splitBy f s = case dropWhile f s of
[] -> []
s' -> w : splitBy f s''
where (w, s'') = break f s'