summaryrefslogtreecommitdiff
path: root/src/Utility/Split.hs
diff options
context:
space:
mode:
authorJoey Hess2018-12-30 15:08:55 -0400
committerJoey Hess2018-12-30 15:08:55 -0400
commit3328fb83373adad786e57d4ed47e1d801e14260f (patch)
treef1e3502287f2cdd2bc19020f82b5a56ac90d0bbe /src/Utility/Split.hs
parent11b3e6c0017dadf64ea67a7ea8c98e78b0917256 (diff)
Merged Utility changes from git-annex
Last done in May 2017..
Diffstat (limited to 'src/Utility/Split.hs')
-rw-r--r--src/Utility/Split.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Utility/Split.hs b/src/Utility/Split.hs
index decfe7d3..ffea5d3f 100644
--- a/src/Utility/Split.hs
+++ b/src/Utility/Split.hs
@@ -28,3 +28,7 @@ splitc c s = case break (== c) s of
-- | same as Data.List.Utils.replace
replace :: Eq a => [a] -> [a] -> [a] -> [a]
replace old new = intercalate new . split old
+
+-- | Only traverses the list once while dropping the last n characters.
+dropFromEnd :: Int -> [a] -> [a]
+dropFromEnd n l = zipWith const l (drop n l)