diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-02 00:53:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-02 00:53:00 -0400 |
commit | d1f49b0ad032f13adc39d963cc8ceca28215b1d5 (patch) | |
tree | 928b469a98f90113822e0300f4c52bd41c6a4863 /Utility/Misc.hs | |
parent | 2d2bfe9809f8d8d5862bc12fbe40c2e25b2405a3 (diff) |
add fields to git-annex-shell
Diffstat (limited to 'Utility/Misc.hs')
-rw-r--r-- | Utility/Misc.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Utility/Misc.hs b/Utility/Misc.hs index 3ac5ca5c0..3b359139b 100644 --- a/Utility/Misc.hs +++ b/Utility/Misc.hs @@ -35,3 +35,13 @@ separate c l = unbreak $ break c l {- Breaks out the first line. -} firstLine :: String-> String firstLine = takeWhile (/= '\n') + +{- Splits a list into segments that are delimited by items matching + - a predicate. (The delimiters are not included in the segments.) -} +segment :: (a -> Bool) -> [a] -> [[a]] +segment p l = map reverse $ go [] [] l + where + go c r [] = reverse $ c:r + go c r (i:is) + | p i = go [] (c:r) is + | otherwise = go (i:c) r is |