summaryrefslogtreecommitdiff
path: root/packages/special/lib/Numeric/GSL/Special/replace.hs
blob: f0f491b60d5899241b18db56e7b4180eab8663c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env runhaskell

import Data.List(isPrefixOf)
import System.Environment(getArgs)

rep (c,r) [] = []
rep (c,r) f@(x:xs) 
  | c `isPrefixOf` f = r ++ rep (c,r) (drop (length c) f)
  | otherwise        = x:(rep (c,r) xs)

main = do
    args <- getArgs
    let [p',r'] = map (rep ("\\n","\n")) args
    interact $ rep (p',r')