Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
open number char monad io string
chars = "ABCDEFGHIJKLMOPQRSTUVWXYZ"
caesar _ _ [] = ""
caesar op key (x::xs) = check shifted ++ caesar op key xs
where orig = indexOf (string.upper $ toString x) chars
shifted = orig `op` key
check val | orig == -1 = x
| val > 24 = trans $ val - 25
| val < 0 = trans $ 25 + val
| else = trans shifted
trans idx = chars:idx
cypher = caesar (+)
decypher = caesar (-)
key = 2
do
putStrLn "A string to encode:"
str <- readStr
putStr "Encoded string: "
cstr <- return <| cypher key str
put cstr
putStrLn ""
putStr "Decoded string: "
put $ decypher key cstr