Write a gofer function map2 that takes a list of functions andlist of values ret
ID: 3611474 • Letter: W
Question
Write a gofer function map2 that takes a list of functions andlist of values returns the list of results from applying eachfunction in the first line to the corresponding value in the secondlist.
Eg: map2 [((*) 2), ((*)2), ((+1)2)] [4,3] yields [8,5]
Explanation / Answer
/* map2[((*)2), ((+1)2)] [4,3] yields [8,5]. Is the "1" i highlighted a typo test with map2[((*)2), ((+)2)] [4,3] yields [8,5]. it worksfine */ listReverse :: [Int] -> [Int] -> [Int] listReverse [] temp = temp listReverse (head : tail) temp = listReverse tail (head: temp) map2helper :: [ Int->Int] -> [Int] -> [Int]-> [Int] map2helper [] [] temp = temp map2helper (head : tail) (p : q) temp = map2helper tail q ( (headp) : temp) map2 :: [ Int->Int] -> [Int] -> [Int] map2 l m = (listReverse (map2helper l m []) [] )
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.