Question: 3: Lazy Evaluation (2.5 marks) For this question, you will consider the following collection of Haskell function definitions and then evaluate whichever of the expressions
3: "Lazy Evaluation" (2.5 marks) For this question, you will consider the following collection of Haskell function definitions and then evaluate whichever of the expressions (of the following page) corresponds to the 2nd LAST DIGIT of your student number.
puzzle :: Int -> Int -> Int puzzle a b = a * b enigma :: Int -> Int -> Int enigma a b = a - b secret :: Int -> Int -> Int secret a b = b - a
If the 2nd LAST DIGIT of your student number is 1, 2, or 3, then trace the evaluation of: enigma (secret (puzzle 1 3) 5) 7 If the 2nd LAST DIGIT of your student number is 4, 5, or 6, then trace the evaluation of: puzzle (enigma (secret 2 4) 6) 8 If the 2nd LAST DIGIT of your student number is 7, 8, 9, or 0, then trace the evaluation of: secret (puzzle (enigma 3 5) 7) 9 To receive full marks for this question you must SHOW (in the correct order) EVERY REDUCIBLE EXPRESSION REPLACEMENT performed by Haskell during the evaluation. n.b., Not counting the initial expression, each of the above expressions can be reduced to an integer final answer using exactly 6 steps. This includes the steps required for evaluating the arithmetic expression. SHOW EVERY STEP and do not hesitate to create and execute the program from the previous page in order to help you confirm your final answer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
