Форматирование кода
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user