Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

Haskell代写|CISC 360 Assignment 2

Haskell代写|CISC 360 Assignment 2



Strive for simplicity

You should try to find a simple solution. You do not have to find the simplest solution to get full marks, but you should not have an excessively complicated solution. Marks may be deducted if your solution is too complicated. If you are worried about whether your solution is too complicated,contact the instructor.

Be careful with library functions

Haskell has a rather large built-in library. This assignment is not about how to find library functions,but about how to use some of the core features of Haskell. You will not receive many marks if you just call a library function that solves the whole problem. The point is to solve the problem yourself.

If you are not sure whether you are calling a library function that solves the whole problem,contact the instructor. Note that if we suggest a library function, you may certainly use it.

(The only way I know to avoid this issue is to craft problems that are complicated and arbitrary,such that no library function can possibly solve them. I don’t like solving complicated and arbitrary problems, and you probably don’t either.)

IMPORTANT: Your file must compile

Your file must load (:load in GHCi) successfully, or we will subtract 30% from your mark.

If you are halfway through a problem and run out of time, comment out the code that is causing :load to fail by surrounding it with {– . . . –}, and write a comment describing what you were trying to do. We can often give (partial) marks for evidence of progress towards a solution,but we need the file to load and compile.

If you choose to work in a group of 2

You must use version control (such as GitHub, GitLab, Bitbucket, etc.). This is primarily to help you maintain an equitable distribution of work, because commit logs provide information about the members’ level of contribution.

Your repository must be private—otherwise, anyone who has your GitHub (etc.) username can copy your code, which would violate academic integrity. However, upon request from the course staff, you must give us access to your repository. (You do not need to give us access unless we ask.)

We only need one submission of the assignment. However, each of you must submit a brief statement.

  1. Give your names and student ID numbers.
  2. Estimate the number of hours you spent on the assignment.
  3. Briefly describe your contribution, and your teammate’s contribution. (Coding, trying to understand the assignment, testing, etc.)

This is meant to ensure that both group members reflect on their relative contributions.

If you do not submit a statement, you will not receive an assignment mark. This is meant to ensure that each group member is at least involved enough to submit a statement. Each member must submit a statement.

Add your student ID

The file a2.hs will not compile until you add your student ID number by writing it after the =:

— Your student ID:

student_id :: Integer

student_id =

You do not need to write your name. When we download your submission, onQ includes your name in the filename.

If you are working in a group of 2, put the second student ID in a comment, like this:

— Your student ID:

student_id :: Integer

student_id = 11112222 — 33334444

1 ‘rewrite’

Haskell has a built-in function ord, with the type

ord :: Char -> Int

When applied to a Char, the ord function returns the ASCII code corresponding to that Char.

For example, ord ’A’ returns 65.

Your task is to implement a function named rewrite. Given a String, rewrite returns a copy of that String with all “important” Chars duplicated.

However, your employer keeps changing their mind about what is important, so the first argument to the function rewrite is a function that tells you whether a given character is important.

For example, if the first argument passed to rewrite is divisible_by 5

then every character whose ASCII code is evenly divisible by 5 is “important” and should be duplicated. (The function divisible_by is already defined in a2.hs.)

If the first argument passed to rewrite is

(\x -> (x == ’ ’))

then every space character (and only space characters) will be considered important.

Some examples:

rewrite (divisible_by 5) “” should evaluate to “”

rewrite (\x -> x == ’ ’) “it’s a deed” should evaluate to “it’s a deed”

rewrite (divisible_by 5) “CombinatorFest” should evaluate to “CombiinnatorFFesst”