Question: Lambda Calculus and Functional Programming Consider the following recursive definition in Haskell for evaluating the factorial of an integer: fact 0 = 1 fact n
Consider the following recursive definition in Haskell for evaluating the factorial of an integer: fact 0 = 1 fact n = n*fact(n-1) We also define a simple function first that takes two arguments and returns the first: first x y = x What will the result be if we ask Haskell to evaluate: first 2 (fact (-5)) The Haskell evaluator will get stuck in an infinite recursion and fail Haskell will provide a warning that fact() is not defined for negative integers The evaluation will terminate with the value 2 being returned The value 2 will be returned and then the evaluator will continue into an infinite recursion
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
