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