Exercise 1 A positive integer is perfect if it equals the sum of all of its factors, excluding the number itself. Using a list comprehension, define a function perfects :: Int -> [Int] that returns the list of all perfect numbers up to a given limit. For example: Ghci>perfects 500 [6,28,496] Ghci> Exercis

Exercise 1

A positive integer is perfect if it equals the sum of all of its factors, excluding the number itself. Using a list comprehension, define a function
perfects :: Int -> [Int]
that returns the list of all perfect numbers up to a given limit. For example:
Ghci>perfects 500
[6,28,496]
Ghci>

Exercise 2

Write a Caesar Cipher program:  example
Text: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Text: ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
The Caesar Cipher technique is one of the earliest and simplest methods of encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is apparently named after Julius Caesar, who apparently used it to communicate with his officials.
Thus, to cipher a given text we need an integer value, known as a shift which indicates the number of position each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n can be described mathematically as.
Examples :
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Text : ATTACKATONCE Shift: 4
Cipher: EXXEGOEXSRGI

Exercise 3

Define the exponentiation operator ^ for non-negative integers using the same pattern of recursion as the multiplication operator *, and show how 2 ^ 3 is evaluated using your definition.

Exercise 4

Define a recursive function merge :: Ord a => [a] -> [a] -> [a] that merges two sorted lists to give a single sorted list. For example:
> merge [2,5,6] [1,3,4]
[1,2,3,4,5,6]
Note: your definition should not use other functions on sorted lists such as insert or sort, but should be defined using explicit recursion.

Report: Has the function been documented correctly?

Code Questions:

  1. Are the applications to be a high level in the knowledge of functional programming?
  2. Did the player has a good interaction with the game?
  3. Did the application use the appreciate data abstraction techniques to design and implement the game?
  4. Does the application provide the functionality required, and is free of buy-in implementation?
  5. Has performed testing?

GET HELP WITH YOUR HOMEWORK PAPERS @ 25% OFF

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

Write My Paper Button

WeCreativez WhatsApp Support
We are here to answer your questions. Ask us anything!
👋 Hi, how can I help?
Scroll to Top