git.iko.soy/typeable/pandoc
on master help sign in
Slight code cleanup on substitute function.
commit5765ac2523434221cbc29fe45e421cc99d97aa3b authorJohn MacFarlane <jgm@berkeley.edu> dateSun 11 Jul 2010, 12:22 (16 years ago) parentda7931f
1 file changed+4−4
src/Text/Pandoc/Shared.hs+4−4
src/Text/Pandoc/Shared.hs+4−4
@@ -109,11 +109,11 @@ splitByIndices (x:xs) lst =
109109-- | Replace each occurrence of one sublist in a list with another.
110110substitute :: (Eq a) => [a] -> [a] -> [a] -> [a]
111111substitute _ _ [] = []
112−substitute [] _ lst = lst
113−substitute target replacement lst =
112+substitute [] _ xs = xs
113+substitute target replacement lst@(x:xs) =
114114 if target `isPrefixOf` lst
115− then replacement ++ (substitute target replacement $ drop (length target) lst)
116− else (head lst):(substitute target replacement $ tail lst)
115+ then replacement ++ substitute target replacement (drop (length target) lst)
116+ else x : substitute target replacement xs
117117
118118--
119119-- Text processing