Project Description
Best Haskell Online Programming assignment help . Available online 24/7 . Please send us an email with the requirement for the quote. Well commented codes.
a) Writing polymorphic functions
Write a polymorphic function that accepts two lists, if the second list is a substring of the first then it should
return the index of the substring and its length. If it is not a substring then it should return (-1,-1). Some
expected output from this function is shown below:
Main> substring [1,4,6,2,4,6,7,2,3] [4,6,7]
(4, 3)
Main> substring “abbacdaacdcfa” “acdc”
(7, 4)
Main> substring [(1,5),(2,4),(6,6),(9,7)] [(2,4),(9,7)]
(-1, -1)
b) Writing a higher-order function
Write a higher-order function that accepts a function and two lists. The higher-order function should return true
if the given function returns true for every pair of elements in the second list and some substring of the first list.
For example:
Main> hsubstring (<) [4,1,2,5,2,4,4] [2,3,6]
(1, 3)
Main> hsubstring (<) [4,1,2,5,2,4,4] [2,3,1]
(-1, -1)
c) Using higher-order functions
Write a higher-order function that accepts a function and three lists. The higher-order should determine if the
second list is a substring of the first. If it is then it should remove it and replace it with the third list, if it is not
then it should return the original list unchanged. Note that the third list may not be the same length.
Main> replace (==) [4,1,2,5,2,4,4] [2,5,2] [4,2,1]
[4,1,4,2,1,4,4]
Main> replace (==) “Hello World!” “World” “159.202 Class”
“Hello 159.202 Class!”
d) Using lambda functions & functional-level definitions
Define a function that can replace substrings in a sentence regardless of whether they are uppercase or lower
case. You should use only a lambda function, a functional-level definition and your previous functions.
Main> replaceString “To be, or not to be, that is the question” “QUESTION” “end”
“To be, or not to be, that is the end”
You must put the following comments at the top of your program code and provide the appropriate information.
— Assignment number, 159.202, 2016 S5
— Family Name, Given Name, Student ID,
— Explain what the program is doing . . .
Hand-in: Submit your script electronically through stream
Project Details
- Date November 3, 2016
- Tags Haskell Programming, Programming