Question

Each of the following ML functions contains a function call that passes a function parameter f....

Each of the following ML functions contains a function call that passes a function parameter f. In each case, will the function f use its nesting link when it is called? Why? (15 points)

fun addone theList =

let fun f x = x + 1;

in map f theList

end;

fun addall n theList =

   let fun f x = x + n;

   in map f theList

   end;

fun do123 f =

   map f [1, 2, 3]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION :-

SOLUTION :- (a) fun addone theLista let fun fx=x+1; in map f theList end; Answer: No, The function addone only utilizes the variable x which has an activation life-span only based on the activation of function f and therefore never requires to utilize the nesting link. (b) fun addall n theList: let fun fxxn; in map f theList endi Answer: Yes, The function addall utilizes the variable x and n both therefore always requires to utilize the nesting link. (c) fun do 123 map f [1, 2, 3] Answer: It can not be determined because it requires to know the definition of f .============================================================================================

Add a comment
Know the answer?
Add Answer to:
Each of the following ML functions contains a function call that passes a function parameter f....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT