Starting from:

$30

Assignment 4 Haskell function

Assignment 4

This assignment is done individually or by a group of 2
* README – 2 points
* Input/output format (including the function name and the number of arguments) – 3
points
1. [15 points] Write a Haskell function maxlist lt that computes the maximum element of list lt
(Assume that the list lt contains at least one element).
E.g. > maxlist [3,1,6,4,2,3] = 6 //the maximum element in the list is 6
2. [20 points] Write a Haskell function delete k lt that removes every kth element of a
list lt.
E.g. > delete 2 [3,4,5,6,7,8,9] //remove the 2nd, 4th, and 6th element
 [3,5,7,9]
3. [15 points] Write a Haskell function isort lt that sorts an integer list lt into ascending
order using the insertion sort.
E.g. > isort [7,3,9,2] = [2,3,7,9]
4. [15 points] Write a Haskell function rotate n lt that rotates a list lt n places to the
right. Assume that lt contains at least n elements.
E.g. > rotate 3 [1,2,3,4,5,6,7] = [5,6,7,1,2,3,4] // rotate the list 3 places to the right
5. [15 points] Write a Haskell function single lt that changes a list lt into a list of lists by
making each element into a singleton list.
E.g. . > single [1,2,3,4] = [[1],[2],[3],[4]]
6. [15 points] Write a Haskell function double lt that doubles every element appearing
the odd positions of lt.
 e.g. > double [1,3,4,5] = [2,3,8,5] //double 1 and 4
Instruction of Submission:
• Write a haskell program assignment4.hs
• Write a README file (text file, do not submit a .doc file) which contains
§ You name and email address.
§ Whether your code was tested on bingsuns or remote.cs.
§ (Optional) Briefly describe anything special about your submission that the
TA should take note of.
• Place assignment4 and README under one directory with a unique name (such
as [userid]_4 for assignment 1, e.g. pyang_4). 
• Tar the contents of this directory using the following command.
tar –cvf [directory_name].tar [directory_name]
E.g. tar -cvf pyang_4.tar pyang_4/
• Upload the tared file you created above on mycourses.
Academic Honesty:
All students should follow Student Academic Honesty Code
(http://watson.binghamton.edu/acadhonorcode.html). All forms of cheating will be treated with
utmost seriousness. You may discuss the problems with other students, however, you must write
your OWN codes and solutions. Discussing solutions to the problem is NOT acceptable. Copying
an assignment from another student or allowing another student to copy your work may lead to an
automatic F for this course. If you borrow small parts of code/text from Internet, you must
acknowledge this in your submission. Also, you must clearly understand and be able to explain
the material. Copying entire material or large parts of such material from the Internet will be
considered academic dishonesty. Moss will be used to detect plagiarism in programming
assignments. You need ensure that your code and documentation are protected and not accessible
to other students. Use chmod 700 command to change the permissions of your working
directories before you start working on the assignments. If you have any questions about whether
an act of collaboration may be treated as academic dishonesty, please consult the instructor before
you collaborate.

More products