hi i prepare myself for the exams and i am styding on previous past papers. could anybody give me a model answer to the following question,it would be very helpful to me to work through the answer!
a) Show how to read a line using
getLineand useputStrLnto write out the capitalized version of the line. (15%)b) Consider the following function definition:
mystery :: Ord a => a -> [a] -> [a] mystery x [] = [] mystery x (y:ys) | x <= y = y : mystery x ys | otherwise = x : mystery x ysi) Explain the
Ordconstraint on the first line. (10%)ii) Give the value of the expression
mystery 3 [2,7,1,8]. (10%)iii) What does the function do? (10%)
iv) Define an equivalent function, but without using recursion. (15%)