PL-Assignment 4-a Haskell function maxlist lt that computes the maximum element of list lt Solved

30.00 $ 15.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment

Description

5/5 - (1 vote)

Assignment 4

  1. 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

  1. 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]

  1.  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]
  2. 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

  1. 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]]

  1.  Write a Haskell function double lt that doubles every element appearing the odd positions of l

e.g. > double [1,3,4,5] = [2,3,8,5]  //double 1 and 4

  • PL-HW4-f5yolc.zip