Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9. The Haskell built-in functions fromEnum and toEnum can be used to convert Chars to Ints and vice versa respectively. For example, fromEnum a
9. The Haskell built-in functions fromEnum and toEnum can be used to convert Chars to Ints and vice versa respectively. For example, fromEnum a returns 97, fromEnum b' returns 98, etc., all the way to fromEnum 2' which returns 122 (that is, 97 + 25). Similarly, toEnum 97 returns 'a', toEnum 98 returns 'b' etc. a) Write a Haskell function, shift (k, v), using fromEnum and to Enum, that takes a pair consisting of an Int k and a lower-case Char v as arguments, and returns a lower-case Char which is obtained by circularly shifting the input Charv k times to the right using the 26-character English alphabet: abcdefghijklmnopqrstuvwxyz. E.g., *Main> shift (3, 'a') *Main> shift (3, 'y') You may want to use the library function mod, which outputs its first argument modulo its second argument (in other words, the remainder of the first argument divided by the second argument). E.g., *Main> mod 16 3 1 *Main> mod 17 3 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started