Design recursive functions using base and recursive cases

Assignment Help Programming Languages
Reference no: EM132903801

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.

Attachment:- Functional Programming.rar

Reference no: EM132903801

Questions Cloud

Main features of a lazy functional language : 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
Calculate probability of no claims will be filed : An insurance company has determined that each week an average of five claims are filed in their Atlanta branch. What is the probability that during the next wee
Implementation of the performance management system : Kindly help with a research proposal please. My title is An investigation into the implementation of the Performance Management System
Contrast investors use of capital markets : Contrast investors' use of capital markets and their use of money markets.
Design recursive functions using base and recursive cases : Understand the functional model in which a program is a set of nested expressions and Design recursive functions using base and recursive cases
Describe 21 policies affecting agricultural sectors : Describe 21 policies affecting agricultural sectors and give an example each.
Describe 21 policies affecting agricultural sectors : Describe 21 policies affecting agricultural sectors and give an example each.
Discuss the business ethics of amazon : Please Discuss the business ethics of Amazon selecting a second Headquarters.
How to create and import data into tables in a relational : How to create and import data into Tables in a Relational Database?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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