diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-02-24 13:23:42 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-02-24 13:23:42 +0000 |
commit | 54bcc1fc1e0f9676cb10f627f412eeeea34b5d2c (patch) | |
tree | 3983a0046ce08a2390c5a495aae60fd419c58986 /packages/special/lib/Numeric/GSL/Special/replace.hs | |
parent | aae45de54aca92c5f0f013e46c6d6f65508d76f5 (diff) |
created package hmatrix-special
Diffstat (limited to 'packages/special/lib/Numeric/GSL/Special/replace.hs')
-rw-r--r-- | packages/special/lib/Numeric/GSL/Special/replace.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/special/lib/Numeric/GSL/Special/replace.hs b/packages/special/lib/Numeric/GSL/Special/replace.hs new file mode 100644 index 0000000..f20a6b8 --- /dev/null +++ b/packages/special/lib/Numeric/GSL/Special/replace.hs | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/env runhaskell | ||
2 | |||
3 | import Data.List(isPrefixOf) | ||
4 | import System(getArgs) | ||
5 | |||
6 | rep (c,r) [] = [] | ||
7 | rep (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 | |||
11 | main = do | ||
12 | args <- getArgs | ||
13 | let [p',r'] = map (rep ("\\n","\n")) args | ||
14 | interact $ rep (p',r') | ||