Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!