add dropFromEnd

This commit is contained in:
Joey Hess 2018-11-23 11:24:05 -04:00
parent acb4bcf2db
commit 850d19d038
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 10 additions and 6 deletions

View file

@ -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)