i'm having trouble with this. my decrypt is not working as intended. i've been trying this for a while and still don't understand why it's showing error.
module CaesarCipher where shift :: Char -> Int -> Char shift ch shift = let newChar = ch + shift alphabet = ['a' .. 'z'] ++ ['A' .. 'Z'] ++ ['0' .. '9'] ++ [' '] in if elem ch alphabet then let wrapAround = length alphabet in alphabet !! ((newChar - head alphabet) `mod` wrapAround) else ch encrypt :: String -> Int -> String encrypt text shift = map (shift) text decrypt :: String -> Int -> String decrypt text shift = map (\ch -> shift ch (-shift)) text -- Lambda function for decryption
shift, one being a function that shifts and the other being the amount of shift. Since you need both in the same scope, it would create a problem. Rename one.Char -> Int -> Char' with actual typeInt' * The functionshift' is applied to two value arguments, but its typeInt' has none In the expression: shift ch (- shift) In the first argument ofmap', namely(\ ch -> shift ch (- shift))' | 17 | decrypt text shift = map (\ch -> shift ch (-shift)) text -- Lambda function for decryption