CP50065E Functional Programming Assignment Help and

Post New Homework

CP50065E Functional Programming - University of West London

Learning outcome 1: Understand the functional model in which a program is a set of nested expressions.
Learning outcome 2: Design recursive functions using base and recursive cases.
Learning outcome 3: Understand the main features of a lazy functional language.
Learning outcome 4: Write, understand and analyse functional programs in Haskell.

The assessment consists of two elements:

- For element 1, implement a number of functions and write a short report about your submission.
- For element 2, implement an application and write a short report about your submission.
For each of the two elements, you need to submit a zip file with the source code and one report (as pdf or Word/doc/docx file).
For the source code submission, please note the following:
1. Any code you write must be in Haskell and follow the functional programming paradigm.
2. Your code should be correct, maintainable and readable:
a. Identifiers should have reasonable names hinting and their purpose or function.
b. Code should be reasonably commented:
i. Module files should have a brief outline summarising their contents.
ii. Any non-trivial function should have its purpose explained and arguments listed, including their semantics.
iii. Use of whitespace (tabulators, empty lines, etc.) should be conducive to reading the code.
3. All code in your solutions must be your own. Unless otherwise specified, you can use the full standard prelude, but not any external modules, libraries, packages, or similar, even when these were mentioned in the lecture material or further reading. Unless otherwise mentioned, all modules imported in your code must be your own.
4. You can develop your submission in whatever environment you like (Windows, Macintosh, Linux, you name it), but a common standard is necessary. Therefore, it is a significant requirement that your submission executes correctly on a clean WinGHCi installation as installed on the university computers, without any modifications or additions either to your code, or to the WinGHCi installation. Remote access to the university's WinGHCi installation is available via AppsAnywhere.
5. Some parts of the assessment stipulate strict submission structure (module elements, function arguments, class members, etc.) and identifier values (e.g., names for files, folders, functions, classes, class members, etc.). Meeting these requirements to the letter forms a significant part of the grade.

For the report submission, please note the following:

1. Keep your reports succinct and to the point. Include in the reports what the assessment asks you to include - not more, not less. Do not repeat the task in the reports.

Element 1 - Portfolio module

Task details Implement a module containing four functions and write a short report about your implementation:
Function 1: Return a list of all prime numbers up to a given limit:
A positive integer is a prime number if it is evenly divisible only by itself and 1. Using a list comprehension, define a function
primes_<your_student_number> :: Int -> [Int]
that returns the list of all prime numbers up to a given limit. For example:
primes_<your_student_number> 10
would return
[2,3,5,7]
Function 2: Encrypt text using Caesar's cipher
The Caesar Cipher is one of the earliest and simplest methods of encryption. It's 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. You can assume that the plain text will contain alphanumerical characters only, i.e., it will contain (in that order)
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
Take note of the space character at the end.
For example, with a shift of 1, occurrences of a are replaced by b, occurrences of b are replaced by c, and so on: z is replaced by A, Z is replaced by 1, 1 is replaced by 2, 0 is replaced by the space character, and the space character is replaced by a. With a shift of 2, occurrences of a are replaced by c, occurrences of b are replaced by d, and so on.
You can assume that the plain text will contain alphanumerical characters and spaces only.
Thus, to cipher a given text we need an integer value, known as shift, to indicate the number of position each letter of the text has been moved down. The method is named after Julius Caesar, who historically used it to communicate with his officials.
Define a function
caesarcipher_<your_student_number> :: [Char] -> Int -> [Char]
that take a plain text and a shift, and returns the corresponding cipher text. For example:
caesarcipher_<your_student_number> "Veni vidi vici" 2
would return
"Xgpkbxkfkbxkek"
Function 3: Implement the factorial function
Using recursion, define a function
factorial_<your_student_number> :: Int -> Int
calculating the factorial of a number, that is, the product of all positive integers less than or equal to the given number.
For example:
factorial_<your_student_number> 5
would return
120
Function 4: Merge two sorted lists
Define a recursive function
merge_<your_student_number> :: Ord a => [a] -> [a] -> [a] that merges two sorted lists to give a single sorted list. For example: merge_<your_student_number> [2,5,6] [1,3,4]
would return
[1,2,3,4,5,6]
Note: Your definition should not use other functions on sorted lists such as insert or isort, but should be defined using explicit recursion.

Report
Write a short report (less than 1000 words). For each of the four functions above, the report needs to include a screenshot of the function as executed, and detail how functional programming concepts were applied.
The report should also include a brief overall reflection of what went well, what did not go well, and what you would do differently if you were given a similar task in the future.

Element 2

Title Accounting program
Task details The purpose of this assignment is to apply knowledge gained throughout the module to a design and development project. To this end, implement a small program and write a short report about your implementation:

Accounting program
Write a text-based accounting program for recording transactions to and from an account. A transaction is either a cash withdrawal, a cash deposit, a transfer (to another account) or a receipt, and consists of the transaction value (in Pound Sterling, Dollar, or Euro), a reference field (for recording the purpose), and, if applicable, the sender/receiver account number. The program should have the following features:
Users will be able to deposit and withdraw an amount in cash. The account is in Pound Sterling, but transactions can be either in Pound Sterling, Dollar, or Euros, and should be recorded as such.

The program will have preset exchange rates for Pound Sterling, Dollar and Euro, but the user can change these between transactions.

Transactions can be cancelled. Upon cancellation, the original transaction is kept in the ledger but marked as reversed. And an additional correctional transaction be lodged. (For example, a user deposits 100 Pound Sterling in transaction A. Later, this transaction is cancelled.
Transaction A is then marked as reversed, and a correctional transaction A' is made, withdrawing 100 Pound Sterling.)

Users will further be able to list all transactions and all transaction data, optionally filtered by transaction type (deposit, withdrawal, transfer, receipt) or currency (Pound Sterling, Dollar or Euro), and/or sorted by value, or sender/receiver number.

Users will also be able to search transactions by sender/receiver account number.

Last but not least, users will be able to query the total current account balance and the average transaction value.

The program should have explanatory text as necessary and handle input errors etc. gracefully.

Implement application features in a command processing style. For example, depositing and withdrawing amounts might be recorded via commands such as
receive 100 pound "tax refund" 1234567890
for logging the receipt of 100 Pound Sterling from account no. 1234567890,
withdraw 100 dollar "pocket money" for logging the withdrawal of 100 Dollars, search 1234567890
for listing all transactions to and from account no. 1234567890,
list
to see all transactions, or
list filter "deposit+dollar"
for listing all deposits in dollar.

Report
Write a short report (less than 500 words). The report needs to include eight screenshots showing main application functions (withdraw, deposit, transfer, receive, list, search, cancel, set exchange rate), and detail how functional programming concepts were applied.
The report should also include a brief overall reflection of what went well, what did not go well, and what you would do differently if you were given a similar task in the future.

Note: Need element 2 Only

Attachment:- Functional Programming.rar

Post New Homework
Captcha

Looking tutor’s service for getting help in UK studies or college assignments? Order Now