CP50065E Functional Programming Assignment

Assignment Help Programming Languages
Reference no: EM132903793

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

Reference no: EM132903793

Questions Cloud

How to create and import data into tables in a relational : How to create and import data into Tables in a Relational Database?
Explain the concept of lead and lag indicators : Explain the concept of lead and lag indicators. How would the development of lead and lag indicators link to the development of a robust and effective quality s
Implications of 2015 rule for the competition in industry : 1. What's the dispute that confronted Lego in the courts with Best-Lock? What was the final ruling that the European court reached in 2015 and on which grounds?
What is the Value of a six-month call option : Assume the spot Swiss franc is $0.7020 and the six-month forward rate is $0.6990. What is the Value of a six-month call option
CP50065E Functional Programming Assignment : CP50065E Functional Programming Assignment Help and Solution, University of West London - Assessment Writing Service
How much must he invest today : Newman Quincy wants to withdraw $32,700 each year for 14 years from a fund that earns 10% interest. How much must he invest today
What amount should be reported as retained earnings : The entity sustained net loss of P1,500,000 for the current year. What amount should be reported as retained earnings at year-end
Explain 7 types of decision making : Explain 7 types of decision making. Non-routin decision making areas are so many. Please explain 59 areas.
Find the total cost accumulated in the marketing department : The Long Term Care Plus Company has two service departments - Find the total cost accumulated in the marketing department using the step method

Reviews

Write a Review

Programming Languages Questions & Answers

  Recursive method to search a string for a byrd

Write a recursive method that searches a string for a Byrd. A Byrd has the following properties. Its first character is an 'A'. If it is a two character Byrd then its second and last character is an 'H'.

  Write application to retrieve the telephone number

Consider a program to enter codes of one to eight characters along with an associated telephone number and associated notes. A code can represent a person's name, a person's initials, a place, or anything.

  Catch any thrown exceptions and display bookexception messag

A book publisher has limited the cost of every book they publish to no more than 10 cents per page.

  Create program for hollywood movie rating guide

Create a program for the Hollywood Movie Rating Guide,in which users continuously enter a value from 0 to 4 that indicates the number of stars they are awarding to the Guide's featured movie of the week.

  Benefits of validating the forms

When you are collecting data, you need to consider what data to collect, why you are collecting the data. What are other benefits of validating your forms? How are forms validated? What are some form validation best practices?

  Implementing efficient code on the gpu with cuda

Com4521/Com6521: Parallel Computing with GPUs. The aim of the assignment is to test your understanding and technical ability of implementing efficient code on the GPU with CUDA. You will be expected to benchmark and optimise the implementation of a..

  Determine proper lower bound and upper bound on ?nal value

Determine the proper lower bound and upper bound on the ?nal value of the shared variable tally output by this concurrent program.

  Program to calculate amount person would earn over a period

Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day.

  Develop algorithmic solutions to programming problems

Develop algorithmic solutions to programming problems using Python language - Design this game such that the first Player can be you (the user)

  Write ipo charts for program contains four value functions

Add new C++ source file to project. Name the source file Ch9AppE05. Use Ipo charts you created in step a to code program. Display gross pay with a dollar sign and two decimal places.

  What is the average number of records they have

Which employees (by name) do not have degrees? (the "answer" is Jones, Green, Reagan, Washington)

  Write a class for two instance variables

Write a class named ParkingMeter containing: Two instance variables named timeLeft and maxTime of type int. The value of timeLeft should be initialized to 0.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd