summaryrefslogtreecommitdiff
path: root/lib/Numeric/GSL/Special/replace.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/GSL/Special/replace.hs')
-rw-r--r--lib/Numeric/GSL/Special/replace.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Numeric/GSL/Special/replace.hs b/lib/Numeric/GSL/Special/replace.hs
new file mode 100644
index 0000000..f20a6b8
--- /dev/null
+++ b/lib/Numeric/GSL/Special/replace.hs
@@ -0,0 +1,14 @@
1#!/usr/bin/env runhaskell
2
3import Data.List(isPrefixOf)
4import System(getArgs)
5
6rep (c,r) [] = []
7rep (c,r) f@(x:xs)
8 | c `isPrefixOf` f = r ++ rep (c,r) (drop (length c) f)
9 | otherwise = x:(rep (c,r) xs)
10
11main = do
12 args <- getArgs
13 let [p',r'] = map (rep ("\\n","\n")) args
14 interact $ rep (p',r')