Mercurial > repo
view gktemp/target @ 1348:ec6018972dc0
<GreyKnight> chmod a+x gktemp/target
author | HackBot |
---|---|
date | Thu, 10 Jan 2013 13:29:55 +0000 |
parents | f05a75aa8c33 |
children |
line wrap: on
line source
import Data.List import Data.Char import System.Environment standardURL = "http://esolangs.org/wiki/Main_Page" replace :: (Eq a) => [a] -> [a] -> [a] -> [a] replace _ _ [] = [] replace old new (y:ys) = case stripPrefix old (y:ys) of Nothing -> y : replace old new ys Just ys' -> new ++ replace old new ys' applyGenTemplate :: String -> String -> String -> String -- nick url template -> result applyGenTemplate nick url template = nick ++ ": " ++ replace "^" nick (replace "@" url template) applyTemplate :: String -> String -> String -- nick template -> result applyTemplate nick template = applyGenTemplate nick standardURL template main = do args <- getArgs template <- getLine putStrLn (applyTemplate (args !! 0) template)