Call us +96895672917 | +917736882141

Project Description

haskell-logo

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

 

–Required for ‘toUpper’
import Data.Char

–a)
substring :: (Eq a) => [a] -> [a] -> (Int, Int)
substring x y = substring’ x y 0

— susbstring’: auxiliar function that does the substring but has an extra parameter to count the index of the found substring
— checkEqual a b: checks if all elements from list a are equal to all elements from list b
substring’ [] _ _ = (-1,-1)
substring’ (x:xs) (y:ys) c | x==y && checkEqual xs ys = (c, 1 + length ys)
| otherwise = substring’ xs (y:ys) (c+1)
where
checkEqual _ [] = True
checkEqual (x:xs) (y:ys) | x==y = checkEqual xs ys
| otherwise = False

——————————————————————–
–b)

hsubstring :: (a->a->Bool) -> [a] -> [a] -> (Int, Int)
hsubstring f x y = hsubstring’ f x y 0

— hsubstring’: auxiliar function that does the hsubstring, but has an extra parametrer to count the index of the found substring
— checkFunction f a b: checks if f x y is true for elements x from a and y from b
hsubstring’ _ [] _ _ = (-1, -1)
hsubstring’ f (x:xs) (y:ys) c | f x y && checkFunction f xs ys = (c, 1 + length ys)
| otherwise = hsubstring’ f xs (y:ys) (c + 1)
where
checkFunction _ _ [] = True
checkFunction f (x:xs) (y:ys) | f x y = checkFunction f xs ys
| otherwise = False
——————————————————————–
–c)
replace :: (a->a->Bool) -> [a] -> [a] -> [a] -> [a]
replace f a b c | index > -1 = (take index a) ++ c ++ (drop (index+l) a)
| otherwise = a
where
(index, l) = hsubstring f a b

——————————————————————–
–d)
replaceString :: [Char] -> [Char] -> [Char] -> [Char]
replaceString a b c = replace (\x y->toUpper x == toUpper y) a b c

 

Project Details

  • Date November 3, 2016
  • Tags Haskell Programming, Programming

Leave a reply

sweet bonanza oynagates of olympus demoAviator oynasugar rush demoCasinoslotbig bass bonanza oynabig bass bonanza oynabayan escortTürkiye Escort Bayanbuca escortMaksibet Giriş TwitterPokerklas TwitterMelbet TwitterMercure Casino Giriş Twitterbornova escortfethiye escortmarsbahisEscortSaatlik escortManisa escortGümüşhane escortDeneme Bonusu Veren Sitelercasibomcasibom girişŞişli escortizmir escortDenizli escortMalatya Escortşanlıurfa escortHacklinkBeşiktaş escortAtaşehir escortBeylikdüzü escortkadıköy escortcialisViagraBahis siteleriEsenyurt escortmasözmasözantalya escortbetturkeycasibomdeneme bonusu veren sitelercasibombets10jojobet girişpusulabetbetmatik twitterbaywinGrandpashabetcasibomholiganbetbettilt girişcasibom girişslot sitelerisekabetbetmatikbetkanyonsekabetholiganbetbetmatikcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomhitbetsahabetsahabetbettiltvdcasinoilbetcratosroyalbettümbetbaywindinamobetelexbetsekabetbetkanyonbetmatikbetinetumbetcasibomslot sitelericanlı casino sitelericasino sitelerislot siteleribahis siteleribaywinİnterbahiscasibomcasibomcasibombelugabahismadridbetartemisbetcasibomcasibomsweet bonanza oynagates of olympus demoAviator oynasugar rush demoCasinoslotbig bass bonanza oynabig bass bonanza oynabayan escortTürkiye Escort Bayanbuca escortMaksibet Giriş TwitterPokerklas TwitterMelbet TwitterMercure Casino Giriş Twitterbornova escortfethiye escortmarsbahisEscortSaatlik escortManisa escortGümüşhane escortDeneme Bonusu Veren Sitelercasibomcasibom girişŞişli escortizmir escortDenizli escortMalatya Escortşanlıurfa escortHacklinkBeşiktaş escortAtaşehir escortBeylikdüzü escortkadıköy escortcialisViagraBahis siteleriEsenyurt escortmasözmasözantalya escortbetturkeycasibomdeneme bonusu veren sitelercasibombets10jojobet girişpusulabetbetmatik twitterbaywinGrandpashabetcasibomholiganbetbettilt girişcasibom girişslot sitelerisekabetbetmatikbetkanyonsekabetholiganbetbetmatikcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomhitbetsahabetsahabetbettiltvdcasinoilbetcratosroyalbettümbetbaywindinamobetelexbetsekabetbetkanyonbetmatikbetinetumbetcasibomslot sitelericanlı casino sitelericasino sitelerislot siteleribahis siteleribaywinİnterbahiscasibomcasibomcasibombelugabahismadridbetartemisbetcasibomcasibom
Wordpress themeseotakipçi satın alyol kapanıevden eve nakliyatseowordpress en iyi seo eklentilerikartal antika eşya alanlarwoocommerce baselpgcdpmsaantika alanlarantika alanlarAccident LawyerDental Implantiqosantika eşya alanlarAntika alan yerlergaziantep evden eve nakliyatsakarya evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatığdır evden eve nakliyateskişehir televizyon tamiriderince evden eve nakliyateskişehir protez saçEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatankara gülüş tasarımımaltepe hayır lokmasıtuzla evden eve nakliyatvalizeskişehir web sitesieskişehir web sitesigaziantep evden eve taşımacılıkgaziantep evden eve nakliyatgaziantep evden eve nakliyatçekici ankaragaziantep evden eve taşımacılıkgaziantep evden eve nakliyatantika alanlarizmir evden eve nakliyatikinci el kitap alanlarçankaya evden eve nakliyatankara evden eve nakliyatkitap alanlareskişehir emlakEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatEtimesgut evden eve nakliyathayır lokmasıankara evden eve nakliyatkartal evden eve nakliyattuzla evden eve nakliyatetimesgut evden eve nakliyatankara ofis taşımacılıgıoran evden eve nakliyatMedyumMedyumlarAnkara implant fiyatlarıkadıköy evden eve nakliyateskişehir uydu servisiçankırı evden eve nakliyatmamak evden eve nakliyatgaziantep nakliyatantika alanlareryaman evden eve nakliyatEskişehir uyduistanbul saç ekimidiş eti ağrısıAntalya Çitseo çalışmasıankara implant fiyatlarıankara gülüş tasarımımaldives online casinopoodleporselen kaplama dislerdis beyazlatmaniğde evden eve nakliyatAntika alan yerlerpoodlepomeraniandextools trendingdextools trending botfront run botdextools trending costdextools trending servicezibilyonbetpancakeswap botNewsHair Transplantankara eşya depolamadextools botdextools trending algorithmcoinmarketcap trending botpinksale trending botcoinmarketcap trendingfront running botpancakeswap sniper botuniswap botuniswap sniper botmev botpinksale trending botprediction botpancakeswap prediction botodunpazarı emlaksancaktepe evden eve nakliyatköpek ilanlarıMedyumWordpress themeseotakipçi satın alyol kapanıevden eve nakliyatseowordpress en iyi seo eklentilerikartal antika eşya alanlarwoocommerce baselpgcdpmsaantika alanlarantika alanlarAccident LawyerDental Implantiqosantika eşya alanlarAntika alan yerlergaziantep evden eve nakliyatsakarya evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatığdır evden eve nakliyateskişehir televizyon tamiriderince evden eve nakliyateskişehir protez saçEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatankara gülüş tasarımımaltepe hayır lokmasıtuzla evden eve nakliyatvalizeskişehir web sitesieskişehir web sitesigaziantep evden eve taşımacılıkgaziantep evden eve nakliyatgaziantep evden eve nakliyatçekici ankaragaziantep evden eve taşımacılıkgaziantep evden eve nakliyatantika alanlarizmir evden eve nakliyatikinci el kitap alanlarçankaya evden eve nakliyatankara evden eve nakliyatkitap alanlareskişehir emlakEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatEtimesgut evden eve nakliyathayır lokmasıankara evden eve nakliyatkartal evden eve nakliyattuzla evden eve nakliyatetimesgut evden eve nakliyatankara ofis taşımacılıgıoran evden eve nakliyatMedyumMedyumlarAnkara implant fiyatlarıkadıköy evden eve nakliyateskişehir uydu servisiçankırı evden eve nakliyatmamak evden eve nakliyatgaziantep nakliyatantika alanlareryaman evden eve nakliyatEskişehir uyduistanbul saç ekimidiş eti ağrısıAntalya Çitseo çalışmasıankara implant fiyatlarıankara gülüş tasarımımaldives online casinopoodleporselen kaplama dislerdis beyazlatmaniğde evden eve nakliyatAntika alan yerlerpoodlepomeraniandextools trendingdextools trending botfront run botdextools trending costdextools trending servicezibilyonbetpancakeswap botNewsHair Transplantankara eşya depolamadextools botdextools trending algorithmcoinmarketcap trending botpinksale trending botcoinmarketcap trendingfront running botpancakeswap sniper botuniswap botuniswap sniper botmev botpinksale trending botprediction botpancakeswap prediction botodunpazarı emlaksancaktepe evden eve nakliyatköpek ilanlarıMedyum