# HG changeset patch # User HackBot # Date 1357824280 0 # Node ID 972124ab193fb02730707a25e767bfd42b9d1d6b # Parent 379d72ea85b6734524a3e7f8382af744125ab276 mv ZJCe gktemp/target diff -r 379d72ea85b6 -r 972124ab193f ZJCe --- a/ZJCe Thu Jan 10 13:24:00 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -import Data.List -import Data.Char - -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 - template <- getLine - putStrLn (applyTemplate nick template) - diff -r 379d72ea85b6 -r 972124ab193f gktemp/target --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gktemp/target Thu Jan 10 13:24:40 2013 +0000 @@ -0,0 +1,24 @@ +import Data.List +import Data.Char + +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 + template <- getLine + putStrLn (applyTemplate nick template) +