main :: IO () main = do putStrLn "Generate some exam style questions" putStrLn "Based on some examples" -- Topic: Functions -- QUESTION. Remove as many parantheses as possible add = \x -> \y -> x + y two = ((add 1) 1) -- ANSWER. two' = add 1 1 -- QUESTION. Compute "5+3" by calling the add function. -- ANSWER. fivePlusThree = add 5 3 -- QUESTION. Compute "5+3" by calling the below plus function. plus (x,y) = x + y -- ANSWER. fivePlusThree2 = plus (5,3) -- QUESTION. Provide for an implementation of the "increment" function by -- partially applying add. increment x = x + 1 -- ANSWER. inc = add 1 -- QUESTION. True or false. -- Functional application is left associative. -- ANSWER. True. Why? -- QUESTION. Replace "(+1)" with a semantically equivalent expression that makes use of "add" instead of "+" ex3 = map (+1) [1,2,3] -- ANSWER. ex3' = map (add 1) [1,2,3] -- QUESTION. True or false. -- The following is an example of a pure function. inc2 :: Int -> Int inc2 x = let y = x + 1 in y -- ANSWER. True. Why? -- QUESTION. True or false. -- The following is an example of a impure function. incIO :: Int -> IO Int incIO x = do print "Hi there, what's your name?" s <- getLine return (x+1) -- ANSWER. True. Why?