Move splitBy to more general 'Util' module
This commit is contained in:
13
Util.hs
Normal file
13
Util.hs
Normal 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'
|
||||
Reference in New Issue
Block a user