• # Haskell

    Posté par . En réponse au journal Esod mumixam !. Évalué à 10.

    import Data.Char
    import Data.List
    import System.Environment
    zorglangue :: String -> String
    zorglangue = concatMap capReverse . splitWords
    w :: Char -> Bool
    w x = isAlphaNum x || x == '_' 
    splitWords :: String -> [String]
    splitWords = groupBy (\a -> \b -> w a == w b)
    capReverse :: String -> String
    capReverse xs | not (all w xs) = xs 
    capReverse xs = map cap $ zip (map (\x -> if isUpper x then toUpper else toLower) xs) (reverse xs)
     where cap (f, c) = f c
    main :: IO()
    main = getContents >>= putStrLn . unlines . map zorglangue . lines
    $ echo "Zorglub, Au secours!" | ./zorglangue
    Bulgroz, Ua sruoces!

    J'ai passé un bon vendredi...