coolface

Аргументатор

sdfgh153 аватар
module Main( main ) where 
import System( getArgs )

split :: String -> Char -> [String]
split [] delim = [""]
split (c:cs) delim
| c == delim = "" : rest
| otherwise = (c : head rest) : tail rest
where
rest = split cs delim

arguments_storage1 = "http://ru.wikipedia.org/wiki/"

make_href url title = "<a href='" ++ url ++"'>" ++ title ++ "</a>"

argumentize :: String -> String
argumentize text = foldr (\x y -> x ++ y) "" $
map (\x -> make_href (arguments_storage1 ++ x) x ++ " ") $ split text ' '

main = do
args <- getArgs
print $ argumentize $ foldr (++) "" args

λ runhaskell argumentator.hs "Теперь я могу писать очень аргументированные посты." | pbcopy

RSS-материал