Форматирование кода

This commit is contained in:
2024-11-17 20:20:23 +03:00
parent a69a81d89a
commit d9076f7dfa

View File

@@ -21,19 +21,19 @@ createAlphabetFromText (x:xs)
indexOf :: (Eq t) => [t] -> t -> Int
indexOf [] _ = -1
indexOf (x : xs) target
| x == target = 0
| otherwise = 1 + indexOf xs target
| x == target = 0
| otherwise = 1 + indexOf xs target
encryptCaesar :: [Char] -> Int -> String -> String
encryptCaesar alphabet shift text = map caesarChar text
where
caesarChar c = alphabet !! ((indexOf alphabet c + shift) `mod` length alphabet)
where
caesarChar c = alphabet !! ((indexOf alphabet c + shift) `mod` length alphabet)
decryptCaesar :: [Char] -> Int -> String -> String
decryptCaesar alphabet shift =
encryptCaesar alphabet (alphabetLength - (shift `mod` alphabetLength))
where
alphabetLength = length alphabet
encryptCaesar alphabet (alphabetLength - (shift `mod` alphabetLength))
where
alphabetLength = length alphabet
textToBits :: String -> [Int]
textToBits = concatMap charToBits