Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago