Globally replace text in several files: Difference between revisions

→‎{{header|Haskell}}: Added a variant implementation of `replace`
(→‎{{header|Haskell}}: Added a variant implementation of `replace`)
Line 679:
| a `isPrefixOf` xxs = b <> go (drop w xxs)
| otherwise = x : go xs</lang>
 
and with different library imports, we could also write things like:
<lang haskell>import Data.List (intercalate)
import Data.List.Split (splitOn)
 
replace :: String -> String -> String -> String
replace a b = intercalate b . splitOn a</lang>
 
 
'''Example:'''
<pre>
9,655

edits