Consider the following function: myLister:: [[x]] rightarrow [x] myLister Is = |
ID: 3798443 • Letter: C
Question
Consider the following function: myLister:: [[x]] rightarrow [x] myLister Is = |x | xs leftarrow Is, (length xs 'mod' 2 == 0), x leftarrow xs] What does it return on the following input: Main > myLister ("This", "is", "a", "longish", "sentence"] What does the following function do? functionr:: (Enum t, Num t) => t rightarrow [a] rightarrow ([a]] functionr x Is = [1s++1s | _ leftarrow [l..x]) Describe what it does and give two examples of its output for different inputs. There are errors in this pair of functions for determining whether a non-negative natural number is even or odd. Find the bugs and fix them. isOdd 1 = True isOdd n = isEven n-1 isEven 0 = True isEven m = isOdd m-1Explanation / Answer
Ans.1.
myLister function removes the outer list and combines the elements of th inner list. Therefore, the return value would be:
This is a longish sentence.
Ans.2.
functionr puts the elements in a list.
Eg: functionr("This is a longish sentence") -> ["This", "is", "a", "longish", "distance"]
functionr(4,5,3,2) -> [4, 5, 3, 2]
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.