Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import System.IO
(BufferMode(..), getContents, hSetBuffering, stdin, stdout)
import Data.Char (isAlpha)
split :: String -> (String, String)
split = span isAlpha
parse :: String -> String
parse [] = []
parse l =
let (a, w) = split l
(b, x) = splitAt 1 w
(c, y) = split x
(d, z) = splitAt 1 y
in a <> b <> reverse c <> d <> parse z
main :: IO ()
main =
hSetBuffering stdin NoBuffering >> hSetBuffering stdout NoBuffering >> getContents >>=
putStr . takeWhile (/= '.') . parse >>
putStrLn "."

View file

@ -0,0 +1,31 @@
isAlpha :: Char -> Bool
isAlpha = flip elem $ ['a'..'z'] ++ ['A'..'Z']
parse :: IO ()
parse = do
x <- getChar
putChar x
case () of
_ | x == '.' -> return ()
| isAlpha x -> parse
| otherwise -> do
c <- revParse
putChar c
if c == '.'
then return ()
else parse
revParse :: IO Char
revParse = do
x <- getChar
case () of
_ | x == '.' -> return x
| isAlpha x -> do
c <- revParse
putChar x
return c
| otherwise -> return x
main :: IO ()
main = hSetBuffering stdin NoBuffering >> hSetBuffering stdout NoBuffering >>
parse >> putStrLn ""