diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-07-11 12:22:18 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-07-11 12:22:18 -0700 |
commit | 5765ac2523434221cbc29fe45e421cc99d97aa3b (patch) | |
tree | 26f3f7e4cd69c7590b56f338dd9b5bedb38ae8e1 | |
parent | da7931f35f03acaa9f10b5014dbe7fe1aa807b4f (diff) | |
download | pandoc-5765ac2523434221cbc29fe45e421cc99d97aa3b.tar.gz |
Slight code cleanup on substitute function.
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 6cb7a2b95..578ffa94b 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -109,11 +109,11 @@ splitByIndices (x:xs) lst = -- | Replace each occurrence of one sublist in a list with another. substitute :: (Eq a) => [a] -> [a] -> [a] -> [a] substitute _ _ [] = [] -substitute [] _ lst = lst -substitute target replacement lst = +substitute [] _ xs = xs +substitute target replacement lst@(x:xs) = if target `isPrefixOf` lst - then replacement ++ (substitute target replacement $ drop (length target) lst) - else (head lst):(substitute target replacement $ tail lst) + then replacement ++ substitute target replacement (drop (length target) lst) + else x : substitute target replacement xs -- -- Text processing |